I am developing a Java site in Eclipse. The site depends on JSP files and servlets, and I use a plugin (Eclipse Jetty 5.0.0) to run the site within Eclipse during development. I got this exception when loading a page in the browser:
XXXXX_jsp.java]<|The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
I will eventually run this site on Tomcat, and I am able to solve this issue in Tomcat by adding the following to JspServlet within tomcat_install/conf/web.xml:
<init-param>
<param-name>mappedfile</param-name>
<param-value>false</param-value>
</init-param>
However, I did quite search and was unable to find a similar configuration solution to make it work in Eclipse/Jetty. I could break the method into a few smaller ones, but I want to avoid it. Hope to use a configuration (not code change) to solve this issue.
The JettyJspServlet
supports the same init-params as Tomcat's JspServlet
.
The mappedfile
init-param is there (just set it to something invalid like "foo" and watch the error message pop out "Warning: Invalid value for the initParam mappedFile. Will use the default value of "false"")
You'll need to reference the existing JSP servlet and add those init-parameters to your WEB-INF/web.xml
.
<servlet id="jsp">
<servlet-name>jsp</servlet-name>
<init-param>
<param-name>mappedfile</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
Or create a new webdefault.xml
with this parameter and have your webapp use it with the XML deployables in ${jetty.base}/webapps/${webappid}.xml
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/foo</Set>
<Set name="war"><Property name="jetty.webapps"/>/foobar.war</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/mywebdefault.xml</Set>
</Configure>
The "mappedfile" init-param:
It appears to switch from generating normal print statements in the intermediate *.java file to 1 liner print statements.
This means you are at the razors edge of JavaC support in your JSP file. There are many hard limits to the size of the *.java file on javac, and your JSP file is tickling those limits now.
Some (but not all) javac limits:
If this init-param works for you, then use it.
But if you need to maintain / edit that JSP file, know that you can almost certainly not add to it (only remove).
You'll likely have to refactor it into smaller pieces with imports in the future.