When i am writing a JSP file, i am getting error that it should n't be more than 64 kilo Bytes like that , then I break the code to to different files , now code is working why that limit is there for JSP.
Asked
Active
Viewed 8,305 times
4
-
It can, but it can't *compile* to more than 64k. – user207421 Apr 19 '14 at 10:22
-
possible duplicate of [maximum size of java class / exception table](http://stackoverflow.com/questions/5497495/maximum-size-of-java-class-exception-table) – Mar 29 '15 at 14:50
3 Answers
8
Java has a 64k limit on the size of methods. So when jsp is converted to _jspService method and if method has exceeded the 64kb limit you get "JSP file size limit exceeds..."
But you can overcome this issue is by using dynamic include. For example, if you are using
<%@ include file="jspPage1.jsp" %> (static include) or extract the content of existing jsp page to newJsp page and
replace this to
<jsp:include page="newJspPagee.jsp" /> (dynamic include).
You can find more information here.

Prasad
- 3,785
- 2
- 14
- 23
3
Because a JSP page compiles to a Java class, and there's a hard limit of 64k on the size of a Java class. If the JSP compiles down to a class larger than that limit, then you'll get an error.
You shouldn't really be running into this limit. A JSP larger than that is going to be seriously unmaintainable, so breaking it up into smaller bits is the right thing to do.
1
Use
<!--some text-->
Do not use
<% //some text %>

Emma.Zhang
- 11
- 2
-
Problem with this is all the comments would render in the HTML DOM on the client side. – bellam Nov 24 '20 at 08:46