[8.2] JSP request implicit Object

JSP request implicit Object

JSP request Object is the instance of javax.servlet.http.HttpServletRequest. This object is used to get the HTTP header information, data entered on previous JSP page etc.

Example:

login.jsp
<html>
 <head>
  <title>login</title>
 </head>
 <body> 
  <form action="welcome.jsp">
   <input type="text" name="userName" />
   <input type="submit" value="login"/>
  </form>
 </body>
</html>
welcome.jsp
<html>
 <head>
  <title>request implicit object example</title>
 </head>
 <body> 
  <%
   String userName=request.getParameter("userName");
   if(userName.equals("jai")){
         out.print("Welcome " + userName + ", 
                                        You are successfully logged in.");
   }else{
    out.print("Wrong username.");  
   }
  %>
 </body>
</html>
web.xml
<web-app>
 
  <welcome-file-list>
          <welcome-file>login.jsp</welcome-file>
  </welcome-file-list> 
 
</web-app>

Output:



Enter UserName: jai
Click on login button.