• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call a Java method within <c:if>?

 
Anjali Raman
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have been trying to call a method within <c:if>, but then it threw me Scripting elements ( <%!, <jsp:declaration, <%=, <jsp:expression, <%, <jsp:scriptlet ) are disallowed here...at

The code is given below:
<c:if test="${actionbean.commiterrormsg eq 'connection closed'}" >
<%
actionbean.startTransaction();
%>
</c:if>

What I am doing here is to check if error msg is "connection closed", if it is then I need to call the method startTransaction in ActionBean class.

Can someone pleaseeeeeeeeee help me.. Seems like it does not allow scriplets with <c:if>...


Thanks a ton in advance
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it in a Java class.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65520
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole purpose of the JSTL and EL is to eliminate scriptlets from JSP pages, They are not meant to be used together, and mixing them in a page just makes a mess.

Processing should occur in the page controller, before the JSP page is forwarded to.
 
Anjali Raman
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The whole purpose of the JSTL and EL is to eliminate scriptlets from JSP pages, They are not meant to be used together, and mixing them in a page just makes a mess.

Processing should occur in the page controller, before the JSP page is forwarded to.



Thanks a lot for the reply
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!