You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcin Orlinski <or...@poczta.fm> on 2007/05/02 12:33:11 UTC

Re: [s2] use remoteUser with struts tags

Hello

I disable el because '#' is used by the JSP EL under JSP 2.1 and I use this
character in OGNL expressions. This information is from
http://struts.apache.org/2.x/docs/ognl.html.
OK, disable is wrong word, I should wrote that I set isELignored to true :-)


My first idea was that I can use:

<s:property value="%{#request.getRemoteUser()}" />
or <s:property value="%{#request.isUserInRole('role_name')}" />

but this doesn't work.

I tried too:
<s:property value="%{@ServletActionContext.@getRequest().getRemoteUser()}"
/>
<s:property value="%{getRemoteUser()}" />

I don't have any errors, but result is null.
I'm sure that remoteUser is set, because I have <%= request.getRemoteUser()
%> in my jsp and I see good result ;-)

For <s:property value="%{request.getRemoteUser()}" /> I have error:

12:25:23:085 WARN com.opensymphony.xwork2.util.OgnlValueStack
[http-8080-Processor24];  Caught an exception while evaluating expression
'request.getRemoteUser()' against value stack
java.lang.NullPointerException: target is null for method getRemoteUser


Best regards
Marcin Orlinski



Laurie Harper wrote:
> 
> OGNL in Struts provides access to these scopes via named attributes on 
> the stack (e.g. %{#session.attribute}). It seams quite reasonable to me 
> to want to limit pages to using a single expression language. I don't 
> know if this use case is viable, but it's reasonable to want it :-)
> 
> To the OP: what did you try, and what happened? Post exactly what 
> configuration you set, what you tried in the JSP and what errors or 
> unexpected behaviours you saw as a result.
> 
> L.
> 
> Felipe Rodrigues wrote:
>> Why did you disabled EL and how did you do that?
>> You can use EL with OGNL. OGNL works only with things in its stack, and
>> I'm
>> not sure about how get things from outside its stack, e.g. Session,
>> Request,
>> Context or even Page. To get these values, the best way is use EL.
>> I can't see any reason to don't use EL.
>> 
>> Regards,
>> 
>> Felipe
>> 
>> 
>> Marcin Orlinski wrote:
>>> Hello
>>>
>>> I have problem only in JSP. I have disabled EL and I tried use OGNL. Can
>>> you give me example how to get this information ?
>>>
>>> Best regards.
>>> Marcin OrliƄski
>>>
>>>
>>> Felipe Rodrigues wrote:
>>>> Well,
>>>>
>>>> If you're in a JSP, you can get it direct from the request, even using
>>>> EL
>>>> or using expressions.
>>>> If you're in a action you may want take a look at the documentation.
>>>> Specific in the part of FAQ -> How To.
>>>> You'll find that you can get the request object by implementing the
>>>> interface ServletRequestAware or using the code
>>>> ActionContext.getContext().getRequest().
>>>>
>>>> Using the interface is a better approach. Make your choice. :-)
>>>>
>>>> Regards,
>>>>
>>>> Felipe
>>>>
>>>
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--use-remoteUser-with-struts-tags-tf3656482.html#a10283544
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] use remoteUser with struts tags

Posted by Marcin Orlinski <or...@poczta.fm>.
Works:
%{@org.apache.struts2.ServletActionContext@getRequest().getRemoteUser()}

Best regards
Marcin Orlinski



Dave Newton-4 wrote:
> 
> Does %{#request.remoteUser} work?
> 
> No, it doesn't work (result null).
> It works when I set attribute remoteUser in request. This is
> request.getAttribute("remoteUser"), no request.getRemoteUser(). 
> 
> Best regards
> Marcin Orlinski
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--use-remoteUser-with-struts-tags-tf3656482.html#a10285937
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] use remoteUser with struts tags

Posted by Marcin Orlinski <or...@poczta.fm>.

Does %{#request.remoteUser} work?

No, it doesn't work (result null).
It works when I set attribute remoteUser in request. This is
request.getAttribute("remoteUser"), no request.getRemoteUser(). 

Best regards
Marcin Orlinski


-- 
View this message in context: http://www.nabble.com/-s2--use-remoteUser-with-struts-tags-tf3656482.html#a10284988
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [s2] use remoteUser with struts tags

Posted by Dave Newton <ne...@yahoo.com>.
--- Marcin Orlinski <or...@poczta.fm> wrote:
> <s:property value="%{#request.getRemoteUser()}" />

Does %{#request.remoteUser} work?

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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