Best practices for reducing the size of the service method in generated JSP class files
 Technote (FAQ)
 
Problem
This document contains best practices for reducing the size of the service method in generated Java™ ServerPage (JSP) class files. Following these best practices can avoid JSP compilation errors due to the JVM™ method size limit of 64K.
 
Cause
It is necessary to consider all static includes when creating a JSP in order to avoid creating a translation unit too large for the Java compiler to handle:
  • Static includes increase the size of the translation unit.
  • Nesting static includes can quickly result in a very large JSP.
 
Solution
Be aware of the size and number of static includes
Static includes are those includes that use the JSP include directive:
<%@ include file="value" %>

These includes are processed at the time the JSP is translated. The entire text of the included file is inserted into the including JSP page. The including JSP page size is increased when the include directive is used.

Consider using dynamic includes instead of static includes

Dynamic includes are those includes that use the JSP include standard action:

<jsp:include page="urlSpec" flush="true|false"/>
<jsp:include page="urlSpec" flush="true|false">
<jsp:param ... />
...
</jsp:include>

These includes are processed at runtime, so they do not affect the size of the including JSP page:

  • Dynamically included resources are processes during execution.
  • The response is included in the output of the JSP.
  • This does not affect the size of the including page or increase the risk of a Java compilation failure.

Dynamically included resources are invoked through the request handler of the Web container, so it is slower than static includes.

Try to employ code-reuse techniques instead of copy-paste

If you have sections of JSP code that are repeated, consider moving the code into reusable components such as JavaBeans, custom tags or dynamic includes.

JavaServer Faces and dynamic includes
You can compose a single view from multiple JSP pages using the <jsp:include> standard action or the JSTL <c:import> action:

  • All JSF component custom actions in included pages must be nested inside the <f:subview> custom action.
  • The <f:subview> custom action is part of the JSF Core Tag Library, which is itself nested inside the <f:view> custom action.

Enclose any template text or non-JSF custom actions present in a page included with <jsp:include> or <c:import> need to use the <f:verbatim> custom action. This insures correct use of the RequestDispatcher.include() function.
 
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > JSP
Operating system(s): HP-UX
Software version: 4.0
Software edition:
Reference #: 1192209
IBM Group: Software Group
Modified date: Jun 24, 2005