Professional Documents
Culture Documents
Request Dispatcher Interface
Request Dispatcher Interface
Aim:
Procedure:
else
{
RequestDispatcher j = request.getRequestDispatcher(“error”);
j.forward(request,response);
}
Creating a servlet for cookies
Aim:
To create a servlet that uses cookies to store the number of times a user has
visited a servlet.
Procedure:
The servlet is created for the cokkie for the cookies visited count by cookie
object.
Cookie = new Cookie (“username”,”1951202”);
Response .addcookie(e);
If(j==1)
Out.println(“welcome”);
else
Aim:
To create a servlet to check whether the user has visited the page for the first
time or earlier.
Procedure:
Session.setattribute(“username”,”1951202”);
Check whether one user has visited this page or visited earlie
using
If(j==1) { out.println(“welcome”);}