You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Markus Demetz <ma...@demetz.eu> on 2011/10/11 19:24:50 UTC

Access namespace-name or/and action name from jsp in Struts2

Hi,

I would like to retrieve the name of the current namespace and possibly 
the action from the jsp page using Struts2.
My intention is to assign a css class to a container to have a better 
control of the layout.

e.g.

<div id="maincontainter" class="current-namespace">...</div>

Any hints?
Thank you,
Markus

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


Re: Access namespace-name or/and action name from jsp in Struts2

Posted by DOMERGUE Sebastien <se...@c-s.fr>.
Hi,

first of all, you won't be able to access these directly within the  
jsp. In your action (or in a interceptor), you have to access the  
request (you can use ServletActionContext for instance). Then, with  
this object you can obtain the url, the server name, the uri... A few  
substrings later, you'll have your namespace and action name. Then,  
put it in the response in order to manipulate them in the jsp.
There may be a more beautifull but this one works for me in several projects.

Regards

Sébastien Domergue

Markus Demetz <ma...@demetz.eu> a écrit :

> Hi,
>
> I would like to retrieve the name of the current namespace and  
> possibly the action from the jsp page using Struts2.
> My intention is to assign a css class to a container to have a  
> better control of the layout.
>
> e.g.
>
> <div id="maincontainter" class="current-namespace">...</div>
>
> Any hints?
> Thank you,
> Markus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



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