Click to See Complete Forum and Search --> : JSP Page Forwarding Problem


talha06
07-24-2009, 04:59 AM
Hello to everyone,

I have been in a boring situation in my project.. I can't forward to a jsp page from my servlet.. I found many codes; but none of them worked.. The URL adress never changes.. (Always stays at the same page)

Here's some of codes I tried:

RequestDispatcher rd = request.getRequestDispatcher("/admin.jsp");
rd.forward(request, response);

or

getServletConfig().getServletContext().getRequestDispatcher("/admin.jsp").forward(request, response);

or

response.setHeader("Location","/admin.jsp");

I need ur helps.. Thanx in advance..
Talha

Tom9729
07-27-2009, 03:29 PM
Hi

All forward does is pass the request on to another page. It does not redirect the user.

You want to use JavaScript or a meta tag to redirect the user to a different URL (that's the only way you can change the location bar).

http://www.web-source.net/html_redirect.htm

criterion9
07-27-2009, 03:46 PM
You can do an http header redirect just like in asp, php, and others.

http://www.exampledepot.com/egs/javax.servlet.jsp/redirect.html

talha06
07-27-2009, 03:48 PM
I'm grateful for ur helps.. Thanx a lot.. I'm going to apply ur recommends..