
Develop a web application to print back the inputs from the user(name, date of birth, address). The solution should have a JSP file which accepts the userâ??s name and sent to Servlets which puts the name in the session and which should be forwarded to another servlet / JSP, which shall print the same back to the user from the session.
Tomcat is available in http://localhost:8080 user : admin/password : admin We are keen on coding standards (comments, class/ method/ variable naming convention etc.)

Hi Friend,
Try the following code:
1)form1.jsp:
<html> <form method="post" action="../GetServlet"> <table> <tr><td>Enter Name:</td><td><input type="text" name="name"></td></tr> <tr><td>Enter Address:</td><td><input type="text" name="address"></td></tr> <tr><td></td><td><input type="submit" value="submit"></td></tr> </table> </form> </html>
2)GetServlet.java:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class GetServlet extends HttpServlet {
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
String name=req.getParameter("name");
String address=req.getParameter("address");
res.setContentType("text/html");
PrintWriter out = res.getWriter();
HttpSession session= req.getSession();
session.setAttribute("sname", name);
session.setAttribute("saddress", address);
RequestDispatcher dispatcher = req.getRequestDispatcher("/jsp/form2.jsp");
if (dispatcher != null){
dispatcher.forward(req, res);
}
}
}
3)form2.jsp:
<%
String name= (String)session.getAttribute("sname");
String address=(String)session.getAttribute("saddress");
%>
<html>
<form>
<table>
<tr><td>Your Name is:</td><td><input type="text" value="<%=name%>"></td></tr>
<tr><td>Your Address is:</td><td><input type="text" value="<%=address%>"></td></tr>
</table>
</form>
</html>
Thanks