| Author |
JSTL(EL) Problem
|
Kumar Anupam
Greenhorn
Joined: Oct 30, 2004
Posts: 19
|
|
Hi, I am converting scriptlets to JSTL Expressions. As i am new to it I am, having some problem. Such as. Hope soon I will get a response. Thanks in advance. Kumar Anupam
|
Thanks & Regards<br /> <br />Anupam
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
You may want to change your approach slightly. Scriptlets and JSTL/EL do not share a one to one relationship. JSTL and EL were not intended to be a full programming language. They were intended to fill in the gaps for view code in an architecture were most of the real programming is done in servlets and javabeans. In other words, some of the things you're trying to do really shouldn't be done in JSP. Our esteemed moderator Bear Bibeault has written two very good articles that should answer your questions. http://www.javaranch.com/journal/200510/Journal200510.jsp#a1 http://www.javaranch.com/journal/200508/Journal200508.jsp#a1
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1004
|
|
What Ben said is perfectly true. However a couple of the things you ARE trying to do are very relevant to JSTL 1) <%=HTMLUtils.escapeHtml(formDetailVB.getMode())%> The c ut tag escapes HTML by default. If formDetailVB is an attribute in scope somewhere: <c ut value="${formDetailVB.mode}/> 2) <% String appAction = formDetailVB.getFormType();%> Not translatable. And not necessary. JSTL does not interact with java variables. The JSTL variable space is the attribute scopes: page, request, session, application. The closest equivalent would be the <c:set> tag to set a JSTL variable: <c:set var="appAction" value="${formDetailVB.formType}"/> The java code equivalent to that (just so you see where it goes to): pageContext.setAttribute("appAction", formDetailVB.getFormType(); 3) if (appAction.equals(FormConstants.VALUE_FORM_TYPE_OPEN)) <c:if test="${formDetailVB.formType == FormConstants.VALUE_FORM_TYPE_OPEN}> <c:set var="DISABLE_NAVIGATION" value="FALSE"/> </c:if> See Bear's second article on how to access constants with JSTL. Cheers, evnafets [ November 15, 2005: Message edited by: Stefan Evans ]
|
 |
 |
|
|
subject: JSTL(EL) Problem
|
|
|