1

So recently I have run into an error that I have never encountered.

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

I set the model attribute in the controller, granted the object is fairly large I wouldn't expect for it to throw an error. I started by limiting the code to figure out what was causing the issue. I have read here to remove the <jsp:include and use <%@ include.

Next step I took was to break up the JSP. I realize now that I am building out my Colors and Fonts individually like this

<form:select path="bottom.backgroundColor" class="form-control">
    <form:option value="#000000">Black</form:option>
    <form:option value="#FFFFFF">White</form:option>
    <form:option value="#FF0000">Red</form:option>
    <form:option value="#00FF00">Green</form:option>
    <form:option value="#0000FF">Blue</form:option>
    <form:option value="#F0F000">Yellow</form:option>
    <form:option value="#FF7000">Orange</form:option>
    <form:option value="#600060">Purple</form:option>
    <form:option value="#905030">Brown</form:option>
</form:select>

Removing these items has fixed my issues.

QUESTION: Why? My understanding is that a JSP builds out its own class however it doesn't seem like it took much to break it. Is the problem the size of the modelAttribute that was passed in? It sounds like others have solved issues with loops and such. Can anyone point me to a resource or explain this better? I can supply more code if necessary.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
B Rad
  • 571
  • 3
  • 9
  • 28
  • I think the servlet container just creates a big function with the full contents of the JSP page thus giving you that error. How large is the JSP? – ElderMael Jul 30 '14 at 03:16
  • possible duplicate of [The code of method ... is exceeding the 65535 bytes limit](http://stackoverflow.com/questions/16294505/the-code-of-method-is-exceeding-the-65535-bytes-limit) – ElderMael Jul 30 '14 at 03:22
  • @ElderMael The JSP as it is broken up is 239 lines. All JSPs together are ~650 lines or so. – B Rad Jul 30 '14 at 04:06
  • Its not really a duplicate of the question because its really a question as to why. I have already fixed it. I am really looking for a deeper understanding of what is happening here. – B Rad Jul 30 '14 at 04:08
  • This has helped but I will need to read it several times before I fully understand I think. http://www.cubrid.org/?mid=textyle&category=dev-platform&alias_title=understanding-jvm-internals&vid=blog – B Rad Jul 30 '14 at 04:23

1 Answers1

0

The problem is that your JSP is too large, even after reducing several parts of it. Seems that you still are repeating this part of the JSP code several times (or similar):

<form:select path="bottom.backgroundColor" class="form-control">
    <form:option value="#000000">Black</form:option>
    <form:option value="#FFFFFF">White</form:option>
    <form:option value="#FF0000">Red</form:option>
    <form:option value="#00FF00">Green</form:option>
    <form:option value="#0000FF">Blue</form:option>
    <form:option value="#F0F000">Yellow</form:option>
    <form:option value="#FF7000">Orange</form:option>
    <form:option value="#600060">Purple</form:option>
    <form:option value="#905030">Brown</form:option>
</form:select>

which in the end is fill the _jspService method in the auto generated servlet. A solution for this problem is to store this static data in application scopde a.k.a. ServletContext, and fill the values of your <form:option>s from it.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • I have only really repeated this portion 3 times, which I know is not dry but it was just in place for testing. I don't understand how this piece of code repeated 2 more times is enough to error the page. I'll look into Servlet Context to find more data. So _jspService doesn't take into account the modelAttribute? What are the items that take up the space that the error mentions? – B Rad Jul 30 '14 at 04:13
  • @BRad you can check the generated code when deploying your WAR file into an application server like tomcat and see by yourself. – Luiggi Mendoza Jul 30 '14 at 06:40
  • Oh, thats interesting. How would I go about doing that? Would I simply look for file size? Or is it in one of the logs? – B Rad Jul 30 '14 at 14:06