Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jspinclude with EL  RSS feed

 
Timothy Sam
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...?
 
Alec Lee
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!