• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems while using JSTL and EL together

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
jack wu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jstl 1.0 or jstl 1.1?
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL 1.1
 
Billy Tsai
Ranch Hand
Posts: 1304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you using weblogic?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic