Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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.
 
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
 
Skool. Stay in. Smartness. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic