aspose 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
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: 30537
    
150

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to access session variable in jsp