Byte limit Exceed problem when reloading a jsp page?
Asked Answered
K

7

6

Im new to jsp.I'm getting error is The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

I am using static include such as

<%@ include file="/jsp/common/createScriptMsg.jsp" %> 

but the page is not loading ... I'd also try dynamiac include such as

<jsp:include page="/jsp/common/createScriptMsg.jsp" /> \

NO LUCK..

Any help would be appriciated.

Kangaroo answered 21/9, 2011 at 7:19 Comment(0)
P
14

We "fixed" this here by setting mappedfile to false for JspServlet in our Tomcat-Config. Go to %TOMCAT_HOME%/conf/web.xml and add the following init-param to the JspServlet:

    <init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>

This does not solve the 64 KiB limit but helps in that way that it occurs much later because the generated code is shorter then.

Poultryman answered 27/2, 2012 at 13:8 Comment(0)
A
4

Rather making multiple files i found above mentioned answer's solution more good i-e Adding

<init-param>
        <param-name>mappedfile</param-name>
        <param-value>false</param-value>
    </init-param>

into Web.XML file. but i did not found "JspServlet" in my web.XML file and found a ref link and placed the complete mapping

 <servlet>
         <servlet-name>jsp</servlet-name>
         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param> 
            <param-name>mappedfile</param-name>
             <param-value>false</param-value>
        </init-param>
     </servlet> 

that worked for me. hope this will help someone.

Anaesthesiology answered 30/10, 2014 at 7:13 Comment(2)
helped me. Thanks :)Tussock
It really helped me as well. Thanks.Aparejo
D
2

I have been having this problem since yesterday, I split my JSP into two JSPs using dynamic include <jsp:include,but it alone didn't help me, Make sure you also add all tags lib and import statement. <jsp:includeworks like a function, So if you are breaking up your JSP in two or more they require same import which you have in your original JSP. Hope it works for you, it worked for me.

Dx answered 12/7, 2013 at 0:49 Comment(0)
S
1

When you run Jsp, by default it converts into java code. And in Java, only 65K code can be accommodated inside an single try catch loop. So don't put much code in a single jsp, instead you can import the number of Jsp files into an single jsp file. or else use JSTL.

Stake answered 21/9, 2011 at 7:40 Comment(0)
D
0

In case anyone else stumbles on this, in my case, it was just a JSP with multiple include statements of other JSP files (and some of them more than once), so just checking that everything was included once solved the problem.

Demosthenes answered 22/10, 2012 at 10:45 Comment(0)
Z
0

I have added trimSpaces true also as init-param in tomcat web xml and it resolved the issue.

Zepeda answered 12/6, 2017 at 15:2 Comment(0)
S
-1

Move some of the logic out of your JSP pages and into dedicated beans.

The limit of 65k bytes per Java method is insanely high and only very, very long methods exceed it.

Note also that the length of any strong constants is not included in that method, so you simply have some absurd amount of logic in that single method (note: JSPs are compiled into Servlets, wher the _jspService method holds the main bulk of the content of the JSP).

So you simply have too much logic. You shouldn't have any logic in your JSP at all (only output rendering).

Also note that <%@ include and <jsp:include are simply two different ways to do the same thing in this case, so that won't make a difference.

Stephanstephana answered 21/9, 2011 at 7:29 Comment(3)
hi, 1) how i can make static & dynamic include? dynamic include will resolve this issue ? 2) What is dedicated beans? any link ? Pls help.Infrequent
<%@ include %> and <jsp:include> are in fact very different things. The latter just references the target JSP file as opposed to including it, and it does resolve the 65k bytes problem.Dulaney
Also, if a page is complex and deals with a large number of entity types that it needs to render (in HTML, in JS, whatever), it can exceed the limit even without having actual "business logic" (calculations, operations, database access) in it.Dulaney

© 2022 - 2024 — McMap. All rights reserved.