Reached the 65535 bytes limit

Discussion in 'Java' started by Aj-India, Sep 5, 2005.

  1. Aj-India

    Aj-India Guest

    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
    Aj-India, Sep 5, 2005
    #1
    1. Advertising

  2. "Aj-India" <> wrote in message
    news:...
    > 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
    Jimi Hullegård, Sep 5, 2005
    #2
    1. Advertising

  3. Aj-India wrote:
    > 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
    Andrea Desole, Sep 5, 2005
    #3
  4. Aj-India

    Roedy Green Guest

    On 5 Sep 2005 08:27:31 -0700, "Aj-India" <>
    wrote or quoted :

    >_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.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Sep 5, 2005
    #4
  5. Aj-India <> wrote:
    > 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
    Robert Klemme, Sep 5, 2005
    #5
  6. Aj-India

    jan V Guest

    "Jimi Hullegård" <> wrote in message
    news:eEZSe.30543$...
    > "Aj-India" <> wrote in message
    > news:...
    > > 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.


    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.
    jan V, Sep 5, 2005
    #6
  7. Aj-India

    Roedy Green Guest

    On Mon, 5 Sep 2005 22:40:48 +0200, "Robert Klemme" <>
    wrote or quoted :

    > Try using <jsp:include>


    Is JSP include just a macro text include? If so the size of the
    generated class file would be the same.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Sep 6, 2005
    #7
  8. "Roedy Green" <> wrote in message
    news:...
    > On Mon, 5 Sep 2005 22:40:48 +0200, "Robert Klemme" <>
    > wrote or quoted :
    >
    >> Try using <jsp:include>

    >
    > 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
    Jimi Hullegård, Sep 6, 2005
    #8
  9. Roedy Green wrote:
    >
    > 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
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Sep 6, 2005
    #9
  10. Aj-India

    Roedy Green Guest

    On Tue, 06 Sep 2005 02:15:01 +0100, Thomas Hawtin
    <> wrote or quoted :

    >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 .
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Sep 6, 2005
    #10
  11. Roedy Green wrote:
    > On Mon, 5 Sep 2005 22:40:48 +0200, "Robert Klemme" <>
    > wrote or quoted :
    >
    >
    >>Try using <jsp:include>

    >
    >
    > 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

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Sep 6, 2005
    #11
  12. Aj-India

    Wibble Guest

    Raymond DeCampo wrote:
    > Roedy Green wrote:
    >
    >> On Mon, 5 Sep 2005 22:40:48 +0200, "Robert Klemme" <>
    >> wrote or quoted :
    >>
    >>
    >>> Try using <jsp:include>

    >>
    >>
    >>
    >> 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
    >

    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.
    Wibble, Sep 6, 2005
    #12
  13. Roedy Green wrote:
    > On Tue, 06 Sep 2005 02:15:01 +0100, Thomas Hawtin
    > <> wrote or quoted :
    >
    >
    >>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 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

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Sep 6, 2005
    #13
  14. Aj-India

    Aj-India Guest

    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
    Aj-India, Sep 7, 2005
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elhanan
    Replies:
    0
    Views:
    445
    Elhanan
    May 25, 2006
  2. gabor
    Replies:
    4
    Views:
    564
    Martin v. =?iso-8859-15?q?L=F6wis?=
    Nov 27, 2003
  3. Replies:
    1
    Views:
    1,065
    Victor Bazarov
    Jun 28, 2005
  4. Replies:
    1
    Views:
    854
    Alexey Smirnov
    Apr 6, 2007
  5. Christophe Halatek
    Replies:
    2
    Views:
    257
    Ray at
    Aug 11, 2003
Loading...

Share This Page