Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it in a Java class.
 
Sheriff
Posts: 67260
170
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
 
Those are the largest trousers in the world! Especially when next to this ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!