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.

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</title>
            </head>
            <body>
                        <%
                                    String user=request.getParameter(“userName”);
                                    if(user.equals(“amar”))
                                    {
                                                out.print(“Welcome ” + userName);
                                    }
                                    else
                                    {
                                                out.print(“Wrong username.”);
                                    }
                        %>
            </body>
</html>
Scroll to Top