tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dennis Doubleday" <den...@righthandmanager.com>
Subject What is the rationale: (was RE: is there a better way to do this without JSP Script var)
Date Mon, 05 Aug 2002 14:20:58 GMT
This is not a troll, this is an honest question.

Is there a reason for an experienced Java programmer to prefer JSTL
expression language over just using Java scripting?

Perhaps the EL (or Struts logic tags, which I am currently using) are
simpler for the page designer who doesn't know Java--I can't speak to
that. But my experience has been that I am far more likely to make a
mistake using Struts logic tags than if had just scripted the
conditionals, because I know Java so well. And, although this apparently
would not be a problem with JSTL, with Struts logic you end up putting
redundant tests in because of the lack of an "else" capability, e.g.

<logic:equal {some test condition}>
  ...
</logic:equal>
<logic:notEqual {repeat the same condition, a redundancy that increases
the chance for error and is a maintenance issue}>
  ...
</logic:notEqual>

But in both cases, we seem to be pretending that we are moving scripting
out of the presentation layer, but in reality are simply expressing the
scripting in a different language, whose own particular vocabulary must
now be mastered in addition to Java.

> > > > > > > > > > > Is there a better way to do this without

> JSP Script 
> > > > > > > > > > > var
> > > > > > > > > > >
> > > > > > > > > > > <c:forEach var="rs" items="${question.rows}">
> > > > > > > > > > >   <c:set var="qType" 
> value="${rs.QUESTION_TYPE}" />
> > > > > > > > > > >   <% String sqType =
> > > > > pageContext.getAttribute("qType").toString();
> > > > > > > > > %><br>
> > > > > > > > > > >
> > > > > > > > > > >   <%if (sqType.equals("1")) { %>
> > > > > > > > > > >      <c:set var="controlType" value="radio"
/>
> > > > > > > > > > >   <%} else if (sqType.equals("2"))
{%>
> > > > > > > > > > >      <c:set var="controlType" value="checkbox"
/>
> > > > > > > > > > >   <%} else if (sqType.equals("2"))
{%>
> > > > > > > > > > >      <c:set var="controlType" value="select"
/>
> > > > > > > > > > >      <c:out value=" <select>
"/>
> > > > > > > > > > >   <%} %>
> > > > > > > > > > >
> > > > > > > > > > > </c:forEach>
> > > > > > > > > >
> > > > > > > > > > The following should work:
> > > > > > > > > >
> > > > > > > > > >  <c:forEach var="Rs" items="${questions.rows}">
> > > > > > > > > >    <c:set var="qType" value="${rs.question_type}"
/>
> > > > > > > > > >    <c:choose>
> > > > > > > > > >      <c:when test="${qType == 1}">
> > > > > > > > > >        ...
> > > > > > > > > >
> > > > > > > > > > and so forth.


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message