Custom tag - Jasper compilation error
ybh6336 Jul 5, 2007 10:14 AMHello all,
I am trying to use a simple custom tag in my JSP that sets an attribute on the page. This JSP works fine on both WebLogic and WebSphere, but gives the following compilation error on JBoss:
<org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/].[jsp]> - <Servlet.service() for servlet jsp threw exception> org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 125 in the jsp file: /test/jsp/testCustomTag.jsp Generated servlet error: pageVar cannot be resolved at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) ... ...
The code fragment in the JSP looks as follows:
<util:myCustomTag id="pageVar" attr1="<% attr1 %>" attr2="<%= attr2 %>" attr3="<%= attr3 %>" > <% String pageVar2 = pageVar; %>
And the tag definition in .tld is as follows:
... ... <tag> <name>myCustomTag</name> <tag-class>com.test.MyCustomTag</tag-class> <body-content>JSP</body-content> <description> Just a test tag </description> <variable> <name-from-attribute>id</name-from-attribute> <variable-class>String</variable-class> <declare>true</declare> <scope>AT_END</scope> </variable> <attribute> <name>id</name> <required>true</required> <rtexprvalue>false</rtexprvalue> </attribute> <attribute> <name>attr1</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>attr2</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>attr3</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>attr4</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> ... ...
I enabled 1.5 features by uncommenting the following in deploy\jbossweb-tomcat55.sar\conf\web.xml:
<init-param> <param-name>compilerSourceVM</param-name> <param-value>1.5</param-value> </init-param>
Environment:
- JBoss 4.0.5 GA
- BEA JDK 1.5.0_04
- Windows XP
NOTE - The code fragment above is in a JSP that is an include in another JSP, and <%@ taglib uri="/taglib.tld" prefix="util"%> is declared in the parent JSP. The JSP has been included using the following:
<%@ include file="/test/jsp/testCustomTag.jsp" %>
Is there a JSP specs violation in this code somewhere? I would appreciate any feedback.
Regards.