You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Qunhuan Mei <qm...@qm18.wanadoo.co.uk> on 2009/05/26 18:47:50 UTC

Jsp's java variable access from Strtus tag block

Hi, 
Sorry for my ignorance but could some one tell me how to access java
variable within jsp from struts tag blocks. 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 is wrong. What should be the correct
way in this scenario?

Many thanks in advance,

Qunhuan				




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jsp's java variable access from Strtus tag block

Posted by Chris Pratt <th...@gmail.com>.
I would look into the <s:set> tag.  It should do the trick.
  (*Chris*)

On Tue, May 26, 2009 at 9:47 AM, Qunhuan Mei <qm...@qm18.wanadoo.co.uk> wrote:

> Hi,
> Sorry for my ignorance but could some one tell me how to access java
> variable within jsp from struts tag blocks. 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 is wrong. What should be the correct
> way in this scenario?
>
> Many thanks in advance,
>
> Qunhuan
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Jsp's java variable access from Strtus tag block

Posted by Dave Newton <ne...@yahoo.com>.
Qunhuan Mei wrote:
> Sorry for my ignorance but could some one tell me how to access java
> variable within jsp from struts tag blocks. 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 is wrong. What should be the correct
> way in this scenario?

Personally, if I *was* to use a scriptlet (which I wouldn't), I'd just 
use JSTL instead of the S2 tags.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org