Saturday, August 6, 2016

Write a program to display a list of five websites in a HTML form and visit to the selected website by using Response redirection.

Aim: Write a program to display a list of five websites in a HTML form and visit to the selected website by using Response redirection.


Program:

Redirect.html:



<html>
<body>
<center>
<form name="Form1"
method="get"
action="RD">
<B>Select a website:</B>
<select name="website" size="1">
<option value="www.gvpcew.ac.in">gvpcew</option>
<option value="www.gvpce.ac.in">gvpce</option>
<option value="www.jntuk.ac.in">jntuk</option>
<option value="www.google.com">google</option>
<option value="www.gmail.com">gmail</option>
</select>
<br><br>
<input type=submit value="Submit">
</form>
</body>
</html>

ResponseRedirect.java:

import java.io.IOException;  
import javax.servlet.ServletException;  
import javax.servlet.http.HttpServlet;  
import javax.servlet.http.HttpServletRequest;  
import javax.servlet.http.HttpServletResponse;  
  
public class ResponseRedirect extends HttpServlet 
{  
    public void doGet(HttpServletRequest request, HttpServletResponse response)  
            throws ServletException, IOException 
{  
  
        String name=request.getParameter("website");  
        response.sendRedirect("http://"+name);  
  }  
}  


Output:





Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home