File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Badass: Making Users Awesome this week in the Game Development 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
author & internet detective

Joined: May 26, 2003
Posts: 31634

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:

[OCA 8 book] [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:
subject: How to access session variable in jsp