You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/03/30 20:17:27 UTC
DO NOT REPLY [Bug 28058] New: -
JspRuntimeLibrary.getContextRelativePath() can throw StringIndexOutOfBoundsException
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28058>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28058
JspRuntimeLibrary.getContextRelativePath() can throw StringIndexOutOfBoundsException
Summary: JspRuntimeLibrary.getContextRelativePath() can throw
StringIndexOutOfBoundsException
Product: Tomcat 5
Version: 5.0.19
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Jasper
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: pruchaba_bah@scrb.navy.mil
A program I am working on is throwing an exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
from within
org.apache.jasper.runtime.JspRuntimeLibrary.getContextRelativePath
(JspRuntimeLibrary.java:963)
According to the docs http://jakarta.apache.org/tomcat/tomcat-5.0-
doc/servletapi/javax/servlet/http/HttpServletRequest.html#getServletPath(),
getServletPath() can return an empty string which is what is happening in my
app. The line in question:
uri.substring(0, uri.lastIndexOf('/')) + '/' + relativePath
where uri is an empty string is what is causing this exception to be thrown.
As you can see uri.lastIndexOf is going to return -1 and uri.substring(0, -1)
just does not work.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org