Hello Devs,


In this tutorial, we are going to learn about JSP response implicit object. Response implicit object is mainly used for send response to the client browser after processing the request.

Example of JSP Response implicit object

index.html

<!DOCTYPE html>
<html>
<head>
<title>JSP Session</title>
</head>
<body>
<form action="process.jsp">
<input type="text" placeholder="User id" name="userid"> <br><br>
<input type="text" placeholder="Password" name="password"> <br> <br>
<input type="submit" value="submit"><br>
</form>
</body>
</html>


process.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Session</title>
</head>
<body>
<%
String userid=request.getParameter("userid");
String password=request.getParameter("password");
if(userid.equals("admin") && password.equals("admin123"))
{
response.sendRedirect("success.jsp");
}
else {
response.sendRedirect("error.jsp");
}
%>
</body>
</html>


success.jsp

<!DOCTYPE html>
<html>
<head>
<title>you are Sucessfully logged In</title>
</head>
<body>
<p>Sucess</p>
</body>
</html>


error.jsp

<!DOCTYPE html>
<html>
<head>
<title>Error</title>
</head>
<body>
<p>Error</p>
</body>
</html>


I hope this example helps you.