File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to access session variable in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to access session variable in jsp" Watch "How to access session variable in jsp" New topic
Author

How to access session variable in jsp

Pramod Kumar
Ranch Hand

Joined: Oct 05, 2007
Posts: 40
Hi,

I am putting a value in session,

session.setAttribute("opr","add");


I need to access these value in jsp , how can I access?

in jsp <% HttpSession session = request.getSession() %>

<bean efine id="opr" value="<%=session.getAttribute("opr");%>" />

I need to write the value to jsp page

<bean:write name="opr" />

How can I do this
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

Pramod,
While those will both work, it is good practice to avoid scriplets (Java code) in a JSP.

The bean:define tag does what you want. Try:


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access session variable in jsp
 
Similar Threads
accessing ServletContext parameters
How I then, setup a session var in Struts in JSP
mapping all jsps to single servlets init parameters
Configuration multiple resource DB.
setting a session variable in a 'href'