12, జనవరి 2014, ఆదివారం

http://www.wellho.net/resources/ex.php4?item=j901/svl_right.java

<html>
<head>
<title>Well House Consultants - Servlet demo</title>
</head>
<body bgcolor=white>
<center>
<H1>Form to complete</H1>
<H3>Simple version</H3>
<form action=http://seal:8080/servlet/svl_right>
<table>
<tr>
<td>Identify yourself:</td>
<td><INPUT name=you></td>
</tr>
<tr>
<td>Number of persons:</td>
<td>
<select name=howmany>
<option value=1>One</option>
<option value=2>Two</option>
<option value=3>Three</option>
<option value=4>Four</option>
<option value=5>Over Four</option>
</select>
</td>
</tr>
<tr>
<td>Area:</td>
<td>
<select name=cover>
<option value=worldwide>World</option>
<option value=european>Europe</option>
</select>
</td>
</tr>
<tr>
<td>Finally select:</td>
<td><input type=submit></td>
</tr>
</table>
</form>
</center>
<p>Note - in order for this form to operate, "Servletrunner" must
be running on port 8080 on seal before you press the submit
button.</p>
<p>
Demo by Well House Consultants<br>
www.wellho.co.uk<br>
01225 708225
</body>
</html>
 
 
 
 
/* Servlet to read back and echo to a second frame */

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/* written by graham@wellho.co.uk */
/* Java and internet training and consultancy */

public class svl_right extends HttpServlet
{
    public void doGet (
        HttpServletRequest      request,
        HttpServletResponse     response
    ) throws ServletException, IOException
    {
        PrintWriter             out;
        String                  title = "Well House Consultants";

        String user_name = request.getParameter("you");
        String adults = request.getParameter("owmany");
        String coverwanted = request.getParameter("cover");
        int ac2 = 1+ Integer.parseInt(adults);

        // set content type and other response header fields first
        response.setContentType("text/html");

        // then write the data of the response
        out = response.getWriter();

        out.println("<html><head><title>");
        out.println(title);
        out.println("</title></head><body bgcolor=yellow>");
        out.println("<center><H1>Result Window</H1>");
        out.println("<p>This is your response window.<p>");
        out.println ("Called from "+HttpUtils.getRequestURL (request).toString ());
        out.println ("<p>User called "+user_name+"<br>");
        out.println ("Persons "+adults+"<br>");
        out.println ("Range "+coverwanted+"<p>");
        out.println ("<em>Addanadult gives you "+ac2+" persons!</em><br>");
        out.println("</center></body></html>");
        out.close();
    }
}
 

కామెంట్‌లు లేవు:

కామెంట్‌ను పోస్ట్ చేయండి