Showing posts with label exceeding 65535 bytes JasperException JSP Java Eclipse Apache Tomcat Struts compile. Show all posts
Showing posts with label exceeding 65535 bytes JasperException JSP Java Eclipse Apache Tomcat Struts compile. Show all posts

Tuesday, April 17, 2007

Exceeding the 65535 bytes limit

Quite a while ago, I was working on my server-side Java & JSP application, when I encountered this error:

org.apache.jasper.JasperException: Unable to
compile class for JSP
Generated servlet error:

The code of method
_jspx_meth_html_html_0(javax.servlet.jsp.PageContext) is exceeding the 65535
bytes limit



Last time I hit a code size limit was 14 years ago when I was compiling computer programs in Borland Turbo C. Back then, I found the solution was to split the source files.

In this case, I was using the Struts framework, Eclipse/MyEclipse and trying to load the app with Apache Tomcat 5.5.9. What was happening is all the jsp files are being server-side compiled into too large a file. It won't help then to split the files into more jsp files, as these are all compiled in on the server side.

To solve the problem, I broke out all the javascript functions in the jsps into Javascript (.js) files. These cannot access server data, but they don't count towards the size limit as they are not compiled into the server. This worked; I haven't had any more such problems.

Be sure to put anything that does not have a jsp or struts tag into a JS file and not a JSP file. This will help your application performance and avoid file size caps.

You can also put the jsp content in an html file and use an html include:
<!--#include virtual="my_file.html" -->
or
<!--#include file="my_file.html" -->