Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access session variable in jsp

 
Pramod Kumar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic