I want to know JSP VS servlet with examples & flow..
Printable View
I want to know JSP VS servlet with examples & flow..
Thats very broad question you asked. Its good to use jsp and servlet togethere. So, just create a form in jsp and get those data in servlet.
e.g. // test.jsp
// whatever data we seding the form data to a servlet called "MyServlet" for further processing
<form name = "form1" method = "POST" action = "MyServlet">
Name:<input type = "text" name = "name">
<br>
<input type = "submit" value = "submit">
</form>
//now create a servlet called MyServlet
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
//fetch the form data sent by jsp page
String pname = request.getParameter("name");
//print the name
out.println("You entered:\t"+pname);
}