Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you put a <c:cout> tag inside the `value` attribute of a <c:set> tag?

Tags:

java

jstl

I want to output the value of the xzy variable into the value of the abc variable.

<c:set var="abc" value="<c:out value="${xyz}"/>"/>

I'm getting an error (unterminated <c:set> tag) when I do this.

How do you do this?

like image 987
Chuck Avatar asked Sep 09 '10 22:09

Chuck


People also ask

What is c set in JSTL?

JSTL Core Tags c:set allows to set the result of an expression in a variable within a given scope. Using this tag helps to set the property of 'JavaBean' and the values of the 'java. util. Map' object.

What is c set tag?

It is used to set the result of an expression evaluated in a 'scope'. The <c:set> tag is helpful because it evaluates the expression and use the result to set a value of java. util. Map or JavaBean. This tag is similar to jsp:setProperty action tag.

Which of the following JSTL tags can be used to assign a new property value to an object?

JSTL - Core <c:set> Tag The <c:set> tag is JSTL-friendly version of the setProperty action. The tag is helpful because it evaluates an expression and uses the results to set a value of a JavaBean or a java. util. Map object.


1 Answers

No, you must have well-formed markup. <c:set/> can have body content instead of a value attribute though:

<c:set var="abc"><c:out value="${xyz}" /></c:set>

I would only use this to take advantage of the XML-escaping provided by <c:out/>. Otherwise it's simpler just to set the value="${xyz}".

like image 99
erickson Avatar answered Sep 19 '22 18:09

erickson