You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Assenza, Chris" <ca...@Accessdc.com> on 2001/07/02 19:38:45 UTC

RE: Compiled JSP got too big and produced this Error/ Anyone know of a Solution/Fix?

Unfortunately I've seen it. :-(

-Chris

Here is a previous reply on this subject from Mr. Cooper: 
----------------------------------------------------------------------------
----------------------------------------
I am, unfortunately, intimately familiar with this problem.

The problem is that there is a limit on the size of a compiled method in a 
Java class file, and that limit is what we're running up against. Recall 
that a JSP page is compiled into a servlet, and into essentially only one 
method in that servlet. Hence, if your page contains many, many tags, that 
method becomes too big, and up comes the exception that you're seeing.

There are a couple of (partial) solutions.

1) Break your giant page up into multiple smaller pages and bring them 
together at run time using <jsp:include>. Note that <%...@include> won't work, 
because that's a compile-time include, which will get you straight back to 
the original problem.

2) Look for places to save on tags. For example, the <html:option> tag was 
recently extended to allow the specification of the text to display, so 
that you can replace this:

<html:option ... ><bean:message key="foo"/></html:option>

with this:

<html:option ... key="foo"/>

If you have a lot of cases of this pattern, it can help quite a bit. In 
addition to the <html:option> tag, some other Struts tags allow the same 
shortcut to including the text. Also, you might consider replacing 
<html:option> sequences with <html:options> if you can build an appropriate 
collection up front.

Unfortunately, we can't use solution (1), because our giant page is almost 
entirely one <html:form>. (Please don't ask... :-} ) Many of the <html:*> 
tags won't work if they are on a separate page from the <html:form> tag 
itself. That means I've spent quite some time on option (2).

We have several of our own tags, too, so that was the next place for me to 
look. I discovered that changing some frequently used tags from extending 
BodyTagSupport to extending TagSupport, and marking them with 
<bodycontent>empty</bodycontent> in the .tld file, made a significant 
reduction in generated code size. Of course, this is not always feasible, 
but it helped us quite a bit.

One other trick is to create custom tags for frequently used groups of 
related elements. For example, I created a simple DatePickerTag which is a 
Struts-like tag that combines three drop-down boxes for month, day and 
year, with the localized strings obtained from the JVM, and the current 
values pulled from a bean.

That's about all I can think of that I've tried so far. All our pages are 
now within the limit, but one is very close to breaking it. I really want 
to put a "do not touch" notice on that file!

Hope this helps.

--
Martin Cooper

-----Original Message-----
From: spencers@msoft.com [mailto:spencers@msoft.com]
Sent: Monday, July 02, 2001 1:32 PM
To: struts-user@jakarta.apache.org
Subject: Compiled JSP got too big and produced this Error/ Anyone know
of a Solution/Fix?



Have any of you ever seen anything like this before?  I think that compiled
code for this JSP got too big.

Error: 500
Location: /eCMS/CareManager/PfPatientSummaryBody.jsp
Internal Servlet Error:

javax.servlet.ServletException: (class:
CareManager/_0002fCareManager_0002fPfPatientSummaryBody_0002ejspPfPatientSum
maryBody_jsp_0, method: _jspService signature:
(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletRespo
nse;)V) Illegal target of jump or branch