• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session attributes and JSTL scoped variables

 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I work in a Eproduct Catalogue project. I need to use only JSTL to create session variables in JSP. After that in servlets I require to access the variables already set in c:set var="variableName" scope="session"/>

Are HttpSession attributes and <c:set var="variableName" scope="session"/> same?

please any body give me the solution.

Regards,
Ramesh Kangamuthu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are the same.
Out of curiosity, why are you setting session variables from with your JSP?
This seems backwards, usually, these things get set on the back end and are only displayed in the JSP. If they are set in the JSP it's only for on page usage.
 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,

Thank you for your valuable answer.In my project there is a template JSP where all the component JSPs reside. So to change the content of the template jsp application should go to the servlet and return to the template jsp with an appropriate attribute set.

According to your answer scoped variables set in jsps can not be accessed in servlets but the converse is true isn't?

Give me some program examples.

regards,
Ramesh Kangamuthu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ramesh kangamuthu:

According to your answer scoped variables set in jsps can not be accessed in servlets but the converse is true isn't?


No.

If you set a session scoped variable, from a JSP or servlet, it will be available to all other JSPs and servlets for the life of that user's session.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!