aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problems while using JSTL and EL together Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Problems while using JSTL and EL together" Watch "Problems while using JSTL and EL together" New topic
Author

Problems while using JSTL and EL together

alzamabar
Ranch Hand

Joined: Jul 24, 2002
Posts: 379
Hi, I wrote a custom tag which receives the request object as parameter.

Originally I used the EL sintax:

${pageContext.request} and it worked fine.

However, I had the need of using the <c:url> element from JSTL, so I created a <c:url var="myVar" /> and then in the <a href=".."> I used the <c ut value="${myVar}" />

This caused the following error:


org.apache.jasper.JasperException: /index.jsp(57,15) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:941)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:696)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1475)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:214)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)



Basically the <c ut value="${myVar}" /> was interpreted as an EL expression, resulting in the above error. I thought...Well, no problem. I'll use the ${pageContext.request} from JSTL and for this page I will declare that EL is ignored.

However, after that, I obtained the following exception, this time related to JSTL:


org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
org.apache.jsp.index_jsp._jspx_meth_jemos_recordRequest_0(index_jsp.java:310)
org.apache.jsp.index_jsp._jspService(index_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)



Somehow, the ${pageContext.request} from JSTL didn't resolve to a HttpServletRequest object.

Result...I had to write the following as attribute value for my custom tag:

<myTag request="<%= request %>" />

and it works but...it's a script (bad, bad, bad Marco)


Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD
jack wu
Greenhorn

Joined: Sep 08, 2004
Posts: 10
jstl 1.0 or jstl 1.1?
alzamabar
Ranch Hand

Joined: Jul 24, 2002
Posts: 379
JSTL 1.1
Billy Tsai
Ranch Hand

Joined: May 23, 2003
Posts: 1296
are you using weblogic?


BEA 8.1 Certified Administrator, IBM Certified Solution Developer For XML 1.1 and Related Technologies, SCJP, SCWCD, SCBCD, SCDJWS, SCJD, SCEA,
Oracle Certified Master Java EE 5 Enterprise Architect
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems while using JSTL and EL together
 
Similar Threads
how to use struts specific html taglib?
jsp.error.useBean.notBoth
JSTL tag c:forEach
jsp:include question
getting variable value