You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Shabada, Gnaneshwer" <sh...@toysrus.com> on 2004/10/20 16:26:40 UTC

Session variables using Struts tag in JSP


Can someone tell me how to retrieve session variable values using Struts
tags??

I tried <logi:match> but didn't work. All I am doing is checking for a flag
that I am setting in the session in my Action class like below..

Action Class:
session.setAttribute("loggedUser", "admin");	

JSP:
 <logic:equal name="registrationForm" property="accessLevel" value="1">
	<logic:match name="loggedUser" value="admin">
		<html:button property="Delete" onclick="callDelete();">
		<bean:message key="button.delete" />
		</html:button>
	</logic:match>
</logic:equal> 

and then trying to display my Delete button if the accesslevel is "1" and if
this flag is "admin". When I do this, I get an error saying 


[10/20/04 9:53:18:165 EDT] 618b279f WebGroup      E SRVE0026E: [Servlet
Error]-[Cannot find bean loggedUser in any scope]:
javax.servlet.jsp.JspException: Cannot find bean loggedUser in any scope
	at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:1038)
	at
org.apache.struts.taglib.logic.MatchTag.condition(MatchTag.java:179)


Can I use any other tag to describe both conditions in one tag or is the way
I am doing right?

TIA
Gnan


======================================================================== 
This email message is for the sole use of the intended recipient (s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message. To reply to our email administrator directly, send
an email to EmailAdmin@toysrus.com. 
Toys "R" Us, Inc.

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


Re: Session variables using Struts tag in JSP

Posted by Jeff Beal <jb...@webmedx.com>.
Based on the error message, it looks like you're using the tag 
correctly, but the attribute isn't being set correctly.  I can't see 
anything wrong in the code that you've included.  Forgive me for asking 
this, but are you sure your Action class is being called?

Shabada, Gnaneshwer wrote:
> 
> Can someone tell me how to retrieve session variable values using Struts
> tags??
> 
> I tried <logi:match> but didn't work. All I am doing is checking for a flag
> that I am setting in the session in my Action class like below..
> 
> Action Class:
> session.setAttribute("loggedUser", "admin");	
> 
> JSP:
>  <logic:equal name="registrationForm" property="accessLevel" value="1">
> 	<logic:match name="loggedUser" value="admin">
> 		<html:button property="Delete" onclick="callDelete();">
> 		<bean:message key="button.delete" />
> 		</html:button>
> 	</logic:match>
> </logic:equal> 
> 
> and then trying to display my Delete button if the accesslevel is "1" and if
> this flag is "admin". When I do this, I get an error saying 
> 
> 
> [10/20/04 9:53:18:165 EDT] 618b279f WebGroup      E SRVE0026E: [Servlet
> Error]-[Cannot find bean loggedUser in any scope]:
> javax.servlet.jsp.JspException: Cannot find bean loggedUser in any scope
> 	at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:1038)
> 	at
> org.apache.struts.taglib.logic.MatchTag.condition(MatchTag.java:179)
> 
> 
> Can I use any other tag to describe both conditions in one tag or is the way
> I am doing right?
> 
> TIA
> Gnan
> 
> 
> ======================================================================== 
> This email message is for the sole use of the intended recipient (s) and may
> contain confidential and privileged information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the intended
> recipient, please contact the sender by reply email and destroy all copies
> of the original message. To reply to our email administrator directly, send
> an email to EmailAdmin@toysrus.com. 
> Toys "R" Us, Inc.


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