JSP implicit object "response"

The response object is an instance of a servlet API javax.servlet.http.HttpResponse interface. It represents the server response to client.. This implicit object is generally used to HttpResponse method..
Example of implict object "response" :
index.html
<html> <head> <title>Welcome implict object response example </title> </head> <body> <form action="login.jsp" method="post"> <fieldset> <legend> <font face="Courier New" size="+1" color="red"> Login </font> </legend> <table> <tr> <td>User Name </td> <td> <input type="text" name="userName"> </td> </tr> <tr> <td>Password </td> <td> <input type="text" name="password"> </td> </tr> <tr> <td colspan=2> <input type="submit" value="Login"> </td> </tr> </table> </fieldset> </form> </body> </html>
login.jsp
<%@ page language="java" %> <html> <body> <% String userName = request.getParameter("userName"); String password = request.getParameter("password"); if (userName != null && password != null && userName.equals("Sunil") && password.equals("Kumar")) { response.sendRedirect("welcome.jsp"); } else { response.sendRedirect("index.html"); } %> </body> </html>
welcome.jsp
<%@ page language="java" %> <html> <head> <title>Welcome page</title> </head> <body> <h1>Login Successful.</h1> </body> </html>
Output
response
response
Download this example
 



 

Latest Tutorial


Most Visited Tutorial