Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JSP and String manipulation

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have following code in my JSP. I would like to code it nicer if JSTL
can really do it. I would like to avoid scriplet code if possible.
br
-MP
// selectedOnes is a String that is concatenated

<c:if test="${forwardingEnabled}">
<% selectedOnes = "1"; %>
</c:if>
<c:if test="${ccIncomingEnabled}">
<%
if(selectedOnes.length() == 0)
selectedOnes = "2";
else
selectedOnes += ";2";
%>
</c:if>
<c:if test="${ccOutgoingEnabled}">
<%
if(selectedOnes.length() == 0)
selectedOnes = "3";
else
selectedOnes += ";3";
%>
</c:if>
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<c:set var="name" scope="scope" value="expression"/> for setting values.
 
Author
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use the JSTL "if" tag and then use the "set" tag as described above. In the expression of the value attribute, you can increment your variable. Although I don't believe you can use the post increment operator, you can use regular addition notation. For example,
I'm using the following code in an application:
<c:set var="requests" scope="application" value="${requests + 1}"/>
Good luck.
 
Mike Landis
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
If tag like:
<c:set var="name" scope="scope" value="expression"/>
is used and variable "name" is string, what kind of string manipulation
operations I can use?
Br
MP
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic