aspose file tools*
The moose likes Servlets and the fly likes Redirecting Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Redirecting Problem" Watch "Redirecting Problem" New topic
Author

Redirecting Problem

Sateesh Kumar K
Greenhorn

Joined: Oct 16, 2001
Posts: 11
Hi,
I want to redirect to a new page from my JSP (here it is source.jsp).As my application is running in a secured zone when i use
response.sendRediect("target.jsp")
it is redirecting me to a non secured URL .So i cannot use this(we are using multiple webservers).
But when i use
response.reset();
getServletContext().getRequestDispatcher("target.jsp").forward(request,response);
With this i am able to navigate to the target.jsp page and in the browser the output of the target.jsp is also getting displayed but at the end i am getting the out put of source.jsp also.I mean when i go to view source first the output of target.jsp is coming and then the output of source.jsp..I have used the
<%@ page language="java" autoFlush="false" buffer="20kb"%>
at the begining of my source.jsp page..
We are using the App Server IBM WebSphere.

thanks..
Sateesh
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Sateesh Kumar K:
response.sendRediect("target.jsp")
it is redirecting me to a non secured URL .
Actually, this shouldn't be happening; it smells like a bug in the app server. The response.sendRedirect() method should correctly handle a relative URL.
But when i use
response.reset();
getServletContext().getRequestDispatcher("target.jsp").forward(request,response);
With this i am able to navigate to the target.jsp page and in the browser the output of the target.jsp is also getting displayed but at the end i am getting the out put of source.jsp also.
This looks like the combination of another application server bug combined with one of your own making. I'm willing to bet that you are assuming that the forward never returns (wrong) and don't follow it up with a "return" statement. But what should be happening is that the page you forward to produces its output, then close()s the output stream; the source page will then throw an exception when it attempts to continue writing its own output. You'll never see this exception in the browser as the output stream has already been closed. However, that is not what seems to be happening in your case, the output stream isn't closed and the source output is simply appended. In any case, follow the forward() by a return and you should be fine.
- Peter

[This message has been edited by Peter den Haan (edited October 16, 2001).]
Sateesh Kumar K
Greenhorn

Joined: Oct 16, 2001
Posts: 11
Hi Peter,
Thanks for your reply..I have added the return statement after the forward() method. But still i am facing the same problem..
In our environment first the request goes to iPlanet WebServer(Where we have the SiteMinder WebAgent) and form there to another WebServer(iPlanet) which will redirect it to the WebSphere appserver..
Thanks
Sateesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirecting Problem