• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to access Session variable set in JSP by JSTL tags  RSS feed

 
Tejas rane
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have set key value pair in Session using following command:

<c:set var="param" value="CCC" scope="session" />

accessing same variable in my action class as

session.getAttribute("param");

but i amgetting null.

Please help.
thanks in advance.
P.S Using JSTL is must .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tejas rane wrote:
P.S Using JSTL is must .

Yes. It is.

Why are you setting the scoped variable in a JSP? And is what you posted a simplification, or actual code?

Are the action and JSP in the same session?
 
Tejas rane
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried that as a solution...found in internet that

setting in session is done by keeping scope as: session...

If you can provide and alternative by which i can set a variable in Session and can access in action class when page is submitted?

Have tried above method but getting null in action class..

<c:remove var="Param"> : this works if i have set something in session but <c:set ....> is not working..

Please provide a code snippet if you have any :-)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:st> should work just fine.

But my question is: why is this being done in a JSP in the first place. It's a bit of a red flag.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!