tags:

views:

55

answers:

2

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?

+3  A: 

What about

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

Remember, c:out is basically when you want to write text to the HTML page. In this case you just want to pass the value around, so keep it in variable land. Think of your java code doing this

  String myString = System.out.println("12");

That is about what you are doing... :)

bwawok
This won't produce the same results; no XML escaping occurs with this method.
erickson
+2  A: 

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}".

erickson