Bug 54249 - Fix JSP compilation problem when application context root contains white spaces
Summary: Fix JSP compilation problem when application context root contains white spaces
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 7.0.33
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-05 12:57 UTC by polina.genova
Modified: 2014-02-17 13:50 UTC (History)
0 users



Attachments
Test web application. (2.24 KB, application/octet-stream)
2012-12-05 12:57 UTC, polina.genova
Details
Proposed patch. (911 bytes, patch)
2012-12-05 12:59 UTC, polina.genova
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description polina.genova 2012-12-05 12:57:49 UTC
Created attachment 29698 [details]
Test web application.

Hello, 

I noticed that there is a jsp compilation problem when the application context root contains white spaces.

Steps to reproduce:
Deploy the attached application and request:
http://<host>:<port>/Space%20AppTest/testClassInvoker.jsp

Then the following exception is received in response:

org.apache.jasper.JasperException: Unable to compile class for JSP
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:661)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause 
java.lang.IllegalArgumentException: Negative time
	java.io.File.setLastModified(File.java:1258)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:376)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

I would like to propose a small patch that fixes this. The fix simply moves the decoding in org.apache.naming.resources.DirContextURLConnection.connect() method a little bit earlier.
Without the fix path.startsWith(contextPath + "/") check returns false in our case, as contexPath is in decoded form, while path is not decoded yet.

Thanks and Best Regards,
Polina
Comment 1 polina.genova 2012-12-05 12:59:43 UTC
Created attachment 29699 [details]
Proposed patch.
Comment 2 Mark Thomas 2013-01-02 21:16:03 UTC
For the record, Tomcat 8 is not affected by this bug as it uses a new resources implementation.
Comment 3 Mark Thomas 2013-01-02 21:27:33 UTC
Thanks for the report and the patch. This has been fixed in trunk and 7.0.x and will be included in 7.0.35 onwards.