Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367680

Summary: jsp-file with load-on-startup not precompiled
Product: [RT] Jetty Reporter: Thomas Zimmermann <zimmermann.tho>
Component: jspAssignee: Jan Bartel <janb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: janb, jetty-inbox
Version: unspecified   
Target Milestone: 7.5.x   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Simple war to demonstrate missing load-on-startup behaviour. none

Description Thomas Zimmermann CLA 2011-12-31 09:34:11 EST
Build Identifier: 8.1.0.RC2

The servlet specification says about the <servlet> element:

--
The jsp-file element contains the full path to a JSP file within the web 
application beginning with a “/”. If a jsp-file is specified and the load-on-startup element is present, then the JSP should be precompiled and loaded.
--

So having this in the web.xml:

--
<servlet>
	<servlet-name>index</servlet-name>
	<jsp-file>/index.jsp</jsp-file>
	<load-on-startup>0</load-on-startup>
</servlet>
--

should precompile the jsp on applicaiton startup.

Currently, jetty does not generate the compiled servlets inside the work directory on startup, only after accessing the page.

I checked with Tomcat 7.0.23 for reference and the servlets are generated on startup.

Thank you very much in advance, Jetty is great!


Reproducible: Always

Steps to Reproduce:
1. Deploy webapp with jsp-file and load-on-startup to the /webapp directory.
2. Look in work directory.
Comment 1 Thomas Zimmermann CLA 2011-12-31 09:36:47 EST
Created attachment 208892 [details]
Simple war to demonstrate missing load-on-startup behaviour.

Very simple webapp with some jsps to demonstrate the issue of missing <load-on-startup> behaviour with <jsp-file>s.
Comment 2 Jan Bartel CLA 2012-01-11 00:47:33 EST
Thomas,

You're absolutely correct about this, but I had a look at our code and it seems that its been missing from jetty for forever! Also, looking at the jsp code - and we use the jasper impl from Glassfish - there doesn't seem to be any support code in there to do this either. The Tomcat version of jasper seems to have been modified to support it. I think the best that I can do is to raise a bug over on Glassfish jsp project for them to add support. 

Jan
Comment 3 Jan Bartel CLA 2012-01-11 01:02:37 EST
Tracked at JSP project here: http://java.net/jira/browse/JSP-23
Comment 4 Thomas Zimmermann CLA 2012-01-12 16:32:55 EST
Jan,

Thank you very much for your effort and fast response,
it's very much appreciated.
The bug/feature is not that critical to me, just something I noticed.
I guess passing it on to the glassfish guys resolves it for now.

Thomas
Comment 5 Jan Bartel CLA 2014-04-11 01:16:31 EDT
Just documenting the results of some investigations so that it is not forgotten:

+ jetty 9.2.0.M0 switched to using apache jasper instead of glassfish jasper
+ that didn't resolve this problem as the container needs to take some steps to get the jsp container to pre-compile servlets that are <jsp-file>s:
   + tomcat does this: change the class of the servlet definition for the servlet to be the JspServlet, copy in all the init-params from the main JspServlet instance, and add in the value of the <jsp-file> as an init-param named "jspFile". When the JspServlet is started (because of the <load-on-startup>) it checks for this init-param and calls the compiler on it.
Comment 6 Jan Bartel CLA 2014-05-06 15:22:49 EDT
Fixed for 9.2.0.M1 if you use the apache-jsp module (new in 9.2).

Jan