Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing control to a JSP page from a servlet

Status
Not open for further replies.

cfitzner

Programmer
Nov 17, 2000
14
0
0
BR
Hi all,

I try to pass the control from a Servlet to a JSP-page:

ServletContext sc = this.getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("/admin/customer.jsp");
if (rd!=null) {
// Pass control to the JSP page
try {
rd.forward(req,resp);
} catch (Exception e) {
sc.log("Problem invoking servlet.", e);
}
}


The problem is, that the Adress shown in the BrowserURL is still the same of the Servlet and is not the new URL from my JSP-side to which I passed the control.
Is there anything else possible than using the RequestDispatcher?

Thanxs a lot for all help
 
Yes there is. You could use the sendRedirect method of the request object. The method has a String argument which is a
the url location of the target jsp page.
 
Why is having the same address a problem? This is the whole appeal of the model-controller-view approach. The client should only be interacting with the controller, they shouldn't even have to know a view exists.
Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top