Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

jspinclude with EL  RSS feed

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I was trying to include a page depending on the expression evaluated by EL... Here's what I try to do...




and here's the error that I get..



HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Exception forwarding for name showMenu: org.apache.jasper.JasperException: /WEB-INF/cpanel.jsp(5,2) "${ ((loginFormBean.groupId) == 1) ? <jsp:include page="templates/adminmenubar.jsp"/> : <jsp:include page="templates/adminmenubar.jsp"/> }" contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered "? <", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||", "?", "not", "?", "!", "?", "-", "?", "empty", "?", "true", "?", "false", "?", <INTEGER_LITERAL>, "?", <FLOATING_POINT_LITERAL>, "?", <STRING_LITERAL>, "?", "null", "?", "(", "?", <IDENTIFIER>]
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.WEB_002dINF.errors.success_jsp._jspService(success_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
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:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.jsp.JspException: Exception forwarding for name showMenu: org.apache.jasper.JasperException: /WEB-INF/cpanel.jsp(5,2) "${ ((loginFormBean.groupId) == 1) ? <jsp:include page="templates/adminmenubar.jsp"/> : <jsp:include page="templates/adminmenubar.jsp"/> }" contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered "? <", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||", "?", "not", "?", "!", "?", "-", "?", "empty", "?", "true", "?", "false", "?", <INTEGER_LITERAL>, "?", <FLOATING_POINT_LITERAL>, "?", <STRING_LITERAL>, "?", "null", "?", "(", "?", <IDENTIFIER>]
org.apache.struts.taglib.logic.ForwardTag.doForward(ForwardTag.java:127)
org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:107)
org.apache.jsp.WEB_002dINF.errors.success_jsp._jspx_meth_logic_forward_0(success_jsp.java:161)
org.apache.jsp.WEB_002dINF.errors.success_jsp._jspService(success_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
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:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.27





it works however when I just put strings..




You guys have any ideas...?
 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe we can only include EL within tag but not the other way round. We can't use standard action inside EL expression. Instead, consider jstl:

<c:choose>
<c:when test="${loginFormBean.groupId == 1}">
<jsp:include...>
</c:when>
<c therwise>
<jsp:include...>
</c therwise>
</c:choose>
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply... But what if I wanted to check for String values?




The when tag doesn't seem to work... Thanks a lot!
[ February 13, 2006: Message edited by: Timothy Sam ]
 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is userId a string? if not, then the comparison will not do what you might expect.

In any case, you should use the empty operator for such tests:

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys! I have another problem... But I guess I should put it on a different thread... Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!