• Post Reply Bookmark Topic Watch Topic
  • New Topic

Acessing dynamically generated session scoped attributes in JSP

 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

Is it possible to access dynamically generated session scoped attributes in JSP? For instance, assume I have session variables like C1, C2, .. Cn generated in a servlet and I know the value of n too. Is it now possible to access them in JSP?

BR,
Dps
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If what you are asking is: can session scoped variables established in a servlet be access by a JSP in the same session? Then, yes.
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using JSTL you could use the implicit variable 'sessionScope' to get a map of session attributes.


However I think the design may be better if you put one list/map into session scope, rather than n session attributes, one for each entry.
You could then use the standard jstl forEach loop on the list/map and it implicitly knows its own size.
 
Deepan Ignatius
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Stefan. I will go with the design proposed by you. I hope that will work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!