You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Willie Wheeler <ww...@andrew.cmu.edu> on 2000/09/16 01:27:17 UTC

Tomcat 3.2 beta 4 bug?

Hi all,

	I think that I've found a bug in Tomcat 3.2 beta 4.  In
PageContextImpl, the following bit of code appears in the
getAbsolutePathRelativeToContext() method:

  String uri = (String)
      request.getAttribute("javax.servlet.include.servlet_path");
  if (uri == null)
    uri = ((HttpServletRequest) request).getServletPath();
  String baseURI = uri.substring(0, uri.lastIndexOf('/'));

Problem is that the getAttribute() method on the request is returning a
URI that doesn't contain any / characters at all (at least, the servlet
path to the JSP that I'm using is just 'main.jsp', which means that the
uri.lastIndexOf('/') returns -1, and the call to substring() throws a
StringIndexOutOfBoundsException.

	Willie



Re: Tomcat 3.2 beta 4 bug?

Posted by Willie Wheeler <ww...@andrew.cmu.edu>.
By the way, calling request.getServletPath() does in fact return a servlet
path that begins with a /, so I guess that something is setting
javax.servlet.include.servlet_path incorrectly.  It may help to know that
the StringIndexOutOfBounds is coming up during a jsp:forward (I am
forwarding to main.jsp, which is causing the exception), so maybe the
culprit is RequestDispatcherImpl? 

	Willie


On Fri, 15 Sep 2000, Willie Wheeler wrote:

> Hi all,
> 
> 	I think that I've found a bug in Tomcat 3.2 beta 4.  In
> PageContextImpl, the following bit of code appears in the
> getAbsolutePathRelativeToContext() method:
> 
>   String uri = (String)
>       request.getAttribute("javax.servlet.include.servlet_path");
>   if (uri == null)
>     uri = ((HttpServletRequest) request).getServletPath();
>   String baseURI = uri.substring(0, uri.lastIndexOf('/'));
> 
> Problem is that the getAttribute() method on the request is returning a
> URI that doesn't contain any / characters at all (at least, the servlet
> path to the JSP that I'm using is just 'main.jsp', which means that the
> uri.lastIndexOf('/') returns -1, and the call to substring() throws a
> StringIndexOutOfBoundsException.
> 
> 	Willie
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org
> 
>