wood burning stoves*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to access session variable in jsp" Watch "How to access session variable in jsp" New topic

How to access session variable in jsp

Pramod Kumar
Ranch Hand

Joined: Oct 05, 2007
Posts: 40

I am putting a value in session,


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

Joined: May 26, 2003
Posts: 30356

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