久丰学习Jsp&Servelet的笔记(写出一个 servelet 程序) |
|
日期:2007-5-25 11:44:35 人气:198 [大 中 小] |
|
|
|
//Begin assembling the HTML content out.println("<html><head>"); out.println("<title>Help Page</title></head><body>"); out.println("<h2>Please submit your information</h2>"); //make sure method="post" so that the servlet service method //calls doPost in the response to this form submit out.println( "<form method="post" action ="" + request.getContextPath( ) + "/firstservlet" >"); out.println("<table border="0"><tr><td valign="top">"); out.println("Your first name: </td> <td valign="top">"); out.println("<input type="text" name="firstname" size="20">"); out.println("</td></tr><tr><td valign="top">"); out.println("Your last name: </td> <td valign="top">"); out.println("<input type="text" name="lastname" size="20">"); out.println("</td></tr><tr><td valign="top">"); out.println("Your email: </td> <td valign="top">"); out.println("<input type="text" name="email" size="20">"); out.println("</td></tr><tr><td valign="top">"); out.println("<input type="submit" value="Submit Info"></td></tr>"); out.println("</table></form>"); out.println("</body></html>"); } //doGet public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException ...{ //display the parameter names and values Enumeration paramNames = request.getParameterNames( ); String parName; //this will hold the name of the parameter |
|
出处:本站原创 作者:佚名 |
|
|