Dispatching Requests
First, call the getRequestDispatcher method 
of ServletContext
Supply a URL relative to the Web application root
Example
String url = "/presentations/presentation1.jsp";
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(url);
Second
Call 
forward
to completely transfer control 
to destination page. See following example
Call include to insert output of destination page 
and then continue on. See book.
105
JSP
www.corewebprogramming.com
Forwarding Requests: 
Example Code
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String operation = request.getParameter("operation");
if (operation == null) {
operation = "unknown";
}
if (operation.equals("operation1")) {
gotoPage("/operations/presentation1.jsp",
request, response);
} else if (operation.equals("operation2")) {
gotoPage("/operations/presentation2.jsp",
request, response);
} else {
gotoPage("/operations/unknownRequestHandler.jsp",
request, response);
}
}
106
JSP
www.corewebprogramming.com
53




  

Home

About Services Network Support FAQ Order Contact
 

Java Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved