• 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

JSP and String manipulation  RSS feed

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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: 8934
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!