You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Betty Chang <bc...@edgenuity.com> on 2007/10/04 23:45:32 UTC

why do $req.setAttribute()s show up in my html page

Hi --

I'm sort of a newbie to both struts and velocity.  I converted an existing webwork2.2.4/velocity project to struts2/velocity.  Things seem okay except that my $req.setAttribute("blah",$blah) calls in my .vm files end up showing up on my html page.

Is there something I need to set to avoid this?   (They did not show up with webwork2.2.4)

Thanks

Betty

Re: why do $req.setAttribute()s show up in my html page

Posted by Nathan Bubna <nb...@gmail.com>.
This is really a better question for the Struts2 folks.  WebWork 2.x
must have had an event handler configured to automatically silence
references that resolve to null/void, because
ServletRequest.setAttribute(...) has always returned void.  Either
that or $req was a wrapper  for ServletRequest that returned an empty
string.

For dealing with this, you can either set up a
ReferenceInsertionEventHandler to suppress these or, as i would
recommend, take Claude's suggestion and just use silent notation
$!req.setAttribute('blah', $blah)

On 10/4/07, Betty Chang <bc...@edgenuity.com> wrote:
> Hi --
>
> I'm sort of a newbie to both struts and velocity.  I converted an existing webwork2.2.4/velocity project to struts2/velocity.  Things seem okay except that my $req.setAttribute("blah",$blah) calls in my .vm files end up showing up on my html page.
>
> Is there something I need to set to avoid this?   (They did not show up with webwork2.2.4)
>
> Thanks
>
> Betty
>

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


Re: why do $req.setAttribute()s show up in my html page

Posted by Betty Chang <bc...@edgenuity.com>.
Hi --

Thanks ever so much!   Changing $req. to $request. did the trick.

Betty

----- Original Message ----- 
From: "Claude Brisson" <cl...@renegat.net>
To: "Velocity Users List" <us...@velocity.apache.org>
Sent: Thursday, October 04, 2007 2:58 PM
Subject: Re: why do $req.setAttribute()s show up in my html page


> It's because they are not resolved. Have you tried with $request instead
> of $req ?
>
> Even when unresolved, you can avoid such statements to leak on web pages
> by using "$!req.setAtt..." (you should still be warned in the logs).
>
>
>  Claude
>
> Le jeudi 04 octobre 2007 à 14:45 -0700, Betty Chang a écrit :
>> Hi --
>>
>> I'm sort of a newbie to both struts and velocity.  I converted an
>> existing webwork2.2.4/velocity project to struts2/velocity.  Things
>> seem okay except that my $req.setAttribute("blah",$blah) calls in
>> my .vm files end up showing up on my html page.
>>
>> Is there something I need to set to avoid this?   (They did not show
>> up with webwork2.2.4)
>>
>> Thanks
>>
>> Betty
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
> 


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


Re: why do $req.setAttribute()s show up in my html page

Posted by Claude Brisson <cl...@renegat.net>.
It's because they are not resolved. Have you tried with $request instead
of $req ?

Even when unresolved, you can avoid such statements to leak on web pages
by using "$!req.setAtt..." (you should still be warned in the logs).


  Claude

Le jeudi 04 octobre 2007 à 14:45 -0700, Betty Chang a écrit :
> Hi --
> 
> I'm sort of a newbie to both struts and velocity.  I converted an
> existing webwork2.2.4/velocity project to struts2/velocity.  Things
> seem okay except that my $req.setAttribute("blah",$blah) calls in
> my .vm files end up showing up on my html page.
> 
> Is there something I need to set to avoid this?   (They did not show
> up with webwork2.2.4)
> 
> Thanks
> 
> Betty


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