Not really.
I stumbled upon this doubt when developing my application.
I have a List of Principals on my session. The first element is a
UserPrincipal and the rest are RolePrincipal.
What I want is to simply have in a JSP:
Welcome, USERNAME
And I want to retrieve USERNAME from that list. Which, in Java, is something
like Principals[0].getName()
or iterate through the principals List, see if the Principal is of instance
UserPrincipal and, if true, return the current principal's name.
On a general idea, I'm trying to find:
1) How to retrieve an item from a List using OGNL
2) What's the best approach for getting users info on JSP pages, either:
a) Getting them like <s:property id="assert"
value="[EMAIL PROTECTED]@getRequest().userPrincipal.name}"
/>
b) Developing a custom JSP tag to get these kinds of information (name,
email, etc). This would also be an exercise, as I have never developed a
custom JSP tag library.
So, any feedback on questions 1) and 2) would be great!
Randy Jonasz wrote:
>
> Hello,
>
> On 9/19/07, wild_oscar <[EMAIL PROTECTED]> wrote:
>>
>> Following the latest message, what is the syntax if your session
>> attribute is
>> a List of Principal objects and what you want is an attribute in
>>
>> a) the first object in the list ( principals[0].name)
>>
>> b) the first object of the child principal Principal1
>> (principal1Object.name) ?
>
> If I understand you correctly, couldn't you just write something like
>
> <nested:iterate id="item" property="List" name="Bean">
> <c:out value="${item.property}"/>
> </nested:iterate>
>
> Cheers,
>
> Randy
>
>>
>>
>>
>> Wesley Wannemacher wrote:
>> >
>> > Try -
>> > <s:property value="#session.user.username" />
>> >
>> > -Wes
>> >
>> > -----Original Message-----
>> > From: Diego Ezquerro [mailto:[EMAIL PROTECTED]
>> > Sent: Monday, July 30, 2007 11:30 AM
>> > To: struts
>> > Subject: Struts tags help
>> >
>> > Hi to everybody.
>> >
>> > I'm developing a web app using struts and wanna know if there is a way
>> to
>> > get the session attributes using struts tags.
>> > What i want to do is something like this (within a jsp page):
>> >
>> > <%
>> > User user = (User)session.getAttribute("user");
>> > out.println("Welcome " + user.getUsername() + "!");
>> > %>
>> >
>> > Gettin' the user attribute and then have it available in the whole
>> page.
>> > I've tried <bean:parameter .../> but it doesn't work fine.
>> >
>> > Thanks for the answers.
>> >
>> >
>> >
>> > __________________________________________________
>> > Correo Yahoo!
>> > Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
>> > Regístrate ya - http://correo.espanol.yahoo.com/
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Struts-tags-help-tf4177812.html#a12778998
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> Oscar Developer
> McMaster University
> 75 Frid Street, Hamilton, ON
> 905 525 9140 x27735
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Struts-tags-help-tf4177812.html#a12779691
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]