Reached the 65535 bytes limit

A

Aj-India

Hi,
I am using JSP. I got this error" The code of method
_jspService(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) is exceeding the 65535 bytes
limit ". Is there any way around this? I am now in a position that I
cannot reduce my number of lines of code.
Thx,
Aj
 
J

Jimi Hullegård

Aj-India said:
Hi,
I am using JSP. I got this error" The code of method
_jspService(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) is exceeding the 65535 bytes
limit ". Is there any way around this? I am now in a position that I
cannot reduce my number of lines of code.

Apparently this is a limit in the java language. Try to move some of the
code to another jsp-file, and do an <jsp:include>.

/Jimi
 
A

Andrea Desole

Aj-India said:
Hi,
I am using JSP. I got this error" The code of method
_jspService(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) is exceeding the 65535 bytes
limit ". Is there any way around this? I am now in a position that I
cannot reduce my number of lines of code.

you have to. This message means that you have a very long jsp, which is
translated into a service method that is longer than 64k, which violates
the specification of the JVM.
You can solve the problem reducing the size of the method, for example
you can split the page in fragments and dynamically include them, or use
custom tags.
This message also means, by the way, that you probably have a *very*
long jsp, which means that you should do that anyway
 
R

Roedy Green

_jspService(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) is exceeding the 65535 bytes
limit ". Is there any way around this? I am now in a position that I
cannot reduce my number of lines of code.

"The 65535 limit" can you find out for sure just what limit they are
talking about? That is NOT the Java String size limit. It is a limit
on method size and possibly class size. It might be some limit on the
size of the response.

Assuming it is the size of the method, you must be doing something
quite unusual that you "cannot" reduce the number of lines of code.

There is no way you could write a fatter method since the class file
jump offsets are 16 bits in a method.

You have not shown us the sample code, so I can only talk in
generalities.

Possibly the problem is the initialisation of some huge table.
1. split that off into some separate class.
2. build it offline and serialise it, so all you need is a readObject
to get it back.

Study the code for any sort of encapsulation.

Simply chop the method in two, and call each half with a huge number
of parameters.

Build the method directly in byte code, where perhaps you can be more
efficient than JavaC. See http://mindprod.com/jgloss/jasm.html

Perhaps this class is a DEBE, does everything but eat. Split some of
the functionality off into a different class.

Presumably this class started out as JSP. Consider having part of the
page generated by a different class then inserted.
 
R

Robert Klemme

Aj-India said:
Hi,
I am using JSP. I got this error" The code of method
_jspService(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) is exceeding the 65535 bytes
limit ". Is there any way around this? I am now in a position that I
cannot reduce my number of lines of code.

I bet you can. Try using <jsp:include> as suggested earlier, make use of
tag libs and generally increase the modularity of your code.

robert
 
J

jan V

Jimi Hullegård said:
Apparently this is a limit in the java language.

To be more precise, it's a limit in the JVM. So other languages which also
compile bytecode for the JVM will have the same limit.
 
J

Jimi Hullegård

Roedy Green said:
Is JSP include just a macro text include? If so the size of the
generated class file would be the same.

No. The <%@ include file="page.jsp" %> tag does that (static include). A
<jsp:include page="page.jsp"> is executed at run time, and really only
inserts the _result_ of that page. In the compiled jsp-file it looks like
this in an test I just made:

org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response,
"page.jsp", out, false);

/Jimi
 
T

Thomas Hawtin

Roedy said:
There is no way you could write a fatter method since the class file
jump offsets are 16 bits in a method.

The class file format actually does allow larger methods. jsr_w and
goto_w are there to support 32-bit jumps. A little dance is required to
generate the opposite if opcode branching over a goto_w.

However, debugging information and try/synchronized blocks cannot be
created for code beyond the sixteen bits.

http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#88659

A sufficiently good compiler could fiddle it. I believe Java SE 6 will
have a revised format that allows larger indexes.
Build the method directly in byte code, where perhaps you can be more
efficient than JavaC. See http://mindprod.com/jgloss/jasm.html

Now that's a step back from JSP.

Tom Hawtin
 
R

Roedy Green

Now that's a step back from JSP.

I am assuming he is generating the JSP. I find it hard to imagine
anyone hand writing a single 64K java method. It then becomes not
that big a difference sometimes to generate JSP, Java or byte code
depending on just how regular what you are generating is.

We have been dropping lots of hints, but OP does not seem willing to
share what he is doing .
 
R

Raymond DeCampo

Roedy said:
Is JSP include just a macro text include? If so the size of the
generated class file would be the same.

<jsp:include> is a dynamic, runtime include. <%@include> is a
macro-style, in-line, translation time include.

Ray
 
W

Wibble

Raymond said:
<jsp:include> is a dynamic, runtime include. <%@include> is a
macro-style, in-line, translation time include.

Ray
Its not that uncommon to have to do this. It really
doesn't take that big a jsp to hit this limit. The really annoying
part is that its a runtime error.
 
R

Raymond DeCampo

Roedy said:
I am assuming he is generating the JSP. I find it hard to imagine
anyone hand writing a single 64K java method.

It is really not hard to do that with JSP. All of the code in a JSP
that is not placed in a method via <%! %> tags is grouped into a single
JSP service method. Add in a healthy dose of tags and some static
imports and soon your file is too big. This is a common issue for
newbies to encounter with JSP.
It then becomes not
that big a difference sometimes to generate JSP, Java or byte code
depending on just how regular what you are generating is.

We have been dropping lots of hints, but OP does not seem willing to
share what he is doing .

HTH,
Ray
 
A

Aj-India

Hi,
Thanks for all your response. Maybe I was a bit rash when I stated that
I cannot reduce the number of lines of code. My code has two logical
halves. The second half is the exact replica of the first half except
that it loops through a certain number of times. So i removed the
second half and placed it in another file and did a
response.sendRedirect to this file. The problem was solved. The
application I am doing is a small part in an accounts module called
Trial Balancing. The original file had approx 4,500 lines of code which
resulted in the error.
Thank u once again,
Cheers,
Aj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top