Yes, you can, though I don't really thing it's the right way to go. Basically you use the body content of the <s:set> tag to set the variable to the value of a scriplet expression like so:
<s:set value="fred"><%= myVar%></s:set> Again, there are much better ways of coding modern web applications that resorting to scriplets and I would certainly take the time to eradicate all scriplets from your code as soon as you can, you will be happy you did. (*Chris*) On Wed, May 27, 2009 at 1:01 AM, Qunhuan Mei <q...@qm18.wanadoo.co.uk> wrote: > Hello David and Chris, > > Thank you two very much indeed for your help. > > I have tried <s:set> tag with different scope and seems I can set a > parameter to any value I want, but I can’t set it to the value/variable > from > jsp’s java code block, so I suppose <s:set> may not be applicable to my > requirement. (or I must done something wrong somewhere!? Sorry I might not > have presented the use case clearly in the first place) > > I’ll check the JSTL approach later – I suppose I should use its <set> tag > (to a page scoped attribte?). > > Cheers, > > Qunhuan > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Hi, > Sorry for my ignorance but could some one tell me how to access java code > block's variable in jsp page. See the sample code below (say, from > test.jsp) > > ... > <% > boolean goAhead = true; > int counter = 0; > ... > %> > <s:if test="goAhead"> > ... <!-- go a head and do something --> > </s:if> > <s:if test="counter>0"> > ... <!-- go a head and do something --> > </s:if> > ... > > The reference of goAhead and counter within Struts' if tag is wrong. What > should be the correct way to reference variable from java code block in > this > scenario? > > Many thanks in advance, > > Qunhuan > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >