Write a Java program using servlet for email registration with userid, password, name, address fields and display the details on next page.
Write a Java program using servlet for email registration with userid, password, name, address fields and display the details on next page.
Program:
import java.io.*; import java.net.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class User extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{ resp.setContentType("Text/http:charset=UTF-8"); PrintWriter out = resp.getWriter(); out.print("<html>"); out.print("<head>"); out.print("<title>Today</title>"); out.print("</head>"); out.print("<body>"); out.print("<br>UserId="+resp.getParameter("userid")); out.print("<br>Password="+resp.getParameter("password")); out.print("<br>Name="+resp.getParameter("name")); out.print("<br>Address="+resp.getParameter("address")); out.print("</body>"); out.print("</html>"); } }
/* HTML form */ <html> <body> <form action="/userpass" method="post"> <table> <tr> <td>UserId</td> <td><input type="text" name="userid"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password"></td> </tr> <tr> <td>Name</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Address</td> <td><input type="text" name="address"></td> </tr> <tr> <td><input type="submit" value="submit"></td> </tr> </table> </form> </body> </html>
/* XML */ <web-app> <servlet> <servlet-name>userpass</servlet-name> <servlet-class>User</servlet-class> </servlet> <servlet-mapping> <servlet-name>userpass</servlet-name> <url-pattern>/userpass</url-pattern> </servlet-mapping> </web-app>
Comments
Post a Comment