The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

W.ZH Oct 2014


 Compiling at Jdev for the project get this error:

The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit



When JAVA compile a JSP into a servlet, the entire body of a JSP file will be placed inside a single try block. The limit which a Java block can contain is 64KB.

So that is the reason you see this error.  your JSP/JSPX is too long.



Sometimes we see a rebuild of project can solve this, if not, then you have to split the JSP into small portion and include them to main page.

Perhaps you have extremely a lot of HTML or conditionals in the JSP file. You need to split the JSP file in smaller parts which you include by
<jsp:include>. For example one JSP include file per header, footer, menu, body and/or conditionally displayed parts, etc. It has the additional advantage that it’s better reuseable.

for JSP case:+++++++++++++++++++++++++++++++++

Static include <%@ include %> – During the translation or compilation phase all the included JSP pages are compiled into a single Servlet.

Dynamic include <jsp:include …..> – The dynamically included JSP is compiled into a separate Servlet. It is a separate resource, which gets to process the request, and the content generated by this resource is included in the JSP response.

JVM has a 64kb limit on the size of the method and the entire JSP page is rendered as a single method

(i.e. _jspService (..)). If a JSP page is greater than 64kb. When this method

reaches its JVM limit of 64kb, the JVM throws an error. This error can be overcome by splitting the JSP files and including

them dynamically (i.e. using <jsp:include…….>) because the dynamic includes generate a separate JSP Servlet for each

included file.