Link to home
Start Free TrialLog in
Avatar of gaurih
gaurih

asked on

concatenate string in jstl

<c:forEach var="address" items="${addressList}" varStatus="status">
            <c:set var="firstaddress" value="${address.streetAddress} ${address.extendedAddress} ${address.city } ${address.city } ${address.zipcode }," />
</c:forEach>

Will the firstaddress have the concatenated address separated by comma? What is the right way to concatenate?
Avatar of rrz
rrz
Flag of United States of America image

Your question is not clear. In the above, you are setting a variable named firstaddress. Nothing will be displayed. Also, you are setting all your addresses to the same variable.  Each address in your list will overwrite the one before it.  
Please give us more details.
What is addressList ? A javabean ?  
How do want the data displayed ?  Show us what it should look like in the browser.
Avatar of gaurih
gaurih

ASKER

I need to concatenate different variables in a single variable, I would like to know the method of concatenation of strings
The way you did it above here(in the <c:set> tag) is fine.  
 Are you trying to concatenate all the addresses in the addressList into one variable ?  
Or are you trying to create a new variable for each address ?  
Avatar of gaurih

ASKER

Concatenate all the address in one variable
If you want to concatenate all the addresses into one variable, then you might have to do it in a scriptlet.  
What do you want to do with the variable once all the data is in it ?
What is addressList ?  Is it an ArrayList ?  Does it contain Address objects that are javabeans?
Avatar of gaurih

ASKER

I  will have data in a array like
<address>
<streetadreess>abc</streetaddress>
<zipcode>66788</zipcode>
</address>

In this case I need to concatenate street address and zip code to concatenate and check the length of the complete address
ASKER CERTIFIED SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial