• Post Reply Bookmark Topic Watch Topic
  • New Topic

getAttribute in a jsp  RSS feed

 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to set a value in a jsp page...sending a request frm servlet using
request.setAttribute(string, Object)
now can u guys plz tell me how to access it in jsp
page
the code goes like this...
value = <% request.getAttribute(String s)%>
its giving error C:\Program Files\Apache Tomcat 4.0\work\localhost\_\Login1$jsp.java:68: Invalid type expression.
request.getAttribute("user")
^

An error occured between lines: 55 and 62 in the jsp file: /Login1.jsp
plz help me
TIA
bye Ravi
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
value = <%= request.getAttribute("user")%>
Is value a java variable BTW?
[ April 30, 2002: Message edited by: pradeep bhat ]
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean to use <% session.getAttribute("user"); %>
Also, take note of the javadoc for the method -->
public java.lang.Object getAttribute(java.lang.String name)Returns the object bound with the specified name in this session, or null if no object is bound under the name.
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name
So you're going to need to cast the object to whatever type of object 'value' is.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!