You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sundaram Ramasamy <su...@percipia.com> on 2001/04/17 14:38:52 UTC

problem with redirecting url

Hi,

I am using tomcat 3.2. I am calling servlet like this.

http://localhost/employee/servlet/dispPage?p=sales

from servlet I redirecting to jsp page. But jsp page URL coming like this

http://localhost/employee/servlet/disp.jsp

I want URL like this.

http://localhost/employee/disp.jsp

my servlet forward function like this.

  private void forward( String url, HttpServletRequest request,
HttpServletResponse response)
    throws IOException, ServletException {


etServletConfig().getServletContext().getRequestDispatcher( url).forward(req
uest, response);

      return;
    }

can any one give me some idea for this.

Thanks
sundaram


Re: problem with redirecting url

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 17 Apr 2001, Sundaram Ramasamy wrote:

> Hi,
> 
> I am using tomcat 3.2. I am calling servlet like this.
> 
> http://localhost/employee/servlet/dispPage?p=sales
> 
> from servlet I redirecting to jsp page. But jsp page URL coming like this
> 
> http://localhost/employee/servlet/disp.jsp
> 

Are you talking about the location that shows in your browser?  If so,
that is just the way that RequestDispatcher.forward() works -- it all
happens on the server side, and the browser has no clue what happens.  All
it knows is the location to which it submitted the form.

If you really want to change the value shown in the browser location bar,
you need to use response.sendRedirect() instead.  However, if you do this,
two bad things happen:
* You suffer from worse performance, due to the extra round
  trip from the client
* You can no longer use request attributes to pass information to the
  JSP page.

The best strategy is to simply teach your users to totally ignore the
value shown in the location window -- it is totally irrelevant on a web
application (as opposed to a web site).

Craig McClanahan