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


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.