tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Fernández <afm...@tid.es>
Subject Re: response.sendRedirect vs. requestDispatcher.forward
Date Thu, 31 May 2001 08:39:30 GMT
Hi Andy!

Just a fine point here.

A Yang wrote:
> RequestDispatch.forward takes a URL that is a RELATIVE
> path but also requires a leading slash.

>From the javadoc of ServletRequest.getRequestDispatcher(String):

'The pathname specified may be relative, although it cannot extend
outside the current servlet context. If the path begins with a "/" it is
interpreted as relative to the current context root. This method returns
null if the servlet container cannot return a RequestDispatcher.

The difference between this method and
ServletContext.getRequestDispatcher(String) is that this method can take
a relative path.'

So, if you get your RequestDispatcher from the request, you don't need
the leading "/".

Un saludo,

Alex.

Mime
View raw message