by Dinesh Thakur Category: introduction to Servlet

JSP is a tag-based language, i.e., code is written within specified tags. It is developed by Sun Microsystems. Unlike servlet program, we can write HTML tags within the JSP program, making it easier to build.

When a servlet JSP communication is taking place, it is not just about forwarding the request to a JSP from a servlet. There might be a need to transfer a string value or an object itself.

In the JSP program we use simple HTML tags to take input from the client but we will save the file as a .jsp extension and then we will retrieve the data in the servlet program.




<form action="login" method="get" >

USERNAME <input type='text' name='t1'><br>

PASSWORD <input type='text' name='t2'><br>

<input type="submit" value="login" >

<input type="reset" value="reset" >




import javax.servlet.*;

import javax.servlet.http.*;


public class Login extends HttpServlet


           public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException



               String usname=req.getParameter("t1");

               String pass=req.getParameter("t2");

               PrintWriter pw=res.getWriter();

               pw.println("USERNAME IS : "+usname);

               pw. println (" PASSWORD IS : "+pass) ;




To test the application