sendRedirect() Example Servlets – Send HTML form to Client

sendRedirect() Example Servlets – Send HTML form to Client

It is the modification of the first program Login Validation. The modification is instead of sending INVALID message, a new HTML form is sent to the user wherein the user can fill up again and send. This HTML form is existing already on the server. It is not created on the fly. That is why, I called it as a static form.

Example on sendRedirect() Method

Client Program: File Name: UserPass.html

Servlet Program: File Name:


sendRedirect(String) is a method of HttpServletResponse which is capable of sending a file to the client passed as a string parameter.

Following is the method signature as defined HttpServletResponse interface.

public abstract void sendRedirect(java.lang.String) throws;

Note: sendRedirect() is not a method of ServletResponse.

When user name and password are given correct


the response screen is


When the password is given wrong as hereunder,


the following fresh (new) form is sent.


Leave a Reply

Your email address will not be published. Required fields are marked *