Saturday, December 02, 2006

JSTL <c:set> Tag

Sets values for variables.
Taglib
: http://java.sun.com/jsp/jstl/core (Core)
Prefix: c
Attributes:
value | * = value to set.
var | String = variable holding the value. If not used, target/property MUST be used.
scope | String = scope for var e.g. page, session, request, or application.
target | JavaBean object, Map = collection or bean specified by 'property' below.
property | String = name of the target above.
Example:
<c:set var="pizzaSelected" value="true" />

3 comments:

Anonymous said...

can you please tell me how can i use var="pizzaSelected" value in my jquery function

Anonymous said...

in your jsp type:

jQuery('#my_div_id').text('${pizzaSelected}')

where my_div_id is the id from a div that should contain the value from "pizzaSelected"

interview questions JSP said...

Another useful point is that if value is long enough to fit in attribute we can provide it in the body of set tag. See here for more examples of set tag in JSTL