Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve sessions variables in JSP

 
gm shariff
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am trying to retrieve session variable from servlet to JSP.

In the servlet i am retrieving employeenames from database and storing them in a ArrayList variable then i am setting this variable into the session.

When retrieving the session in the jsp it displays as [empname1, empname2]. i want to display the names in jsp.

Please help how to retrieve them

Thanks in Advance,
sha
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use c:forEach OR use simple scriptlets

<% list = session.getrAttribute("MY_LIST");
Iterator it = list.iterator();
while(it.hasNext()){
.
.
.
%>

But avoid using Java code in JSP, go for first option !
 
Bauke Scholtz
Ranch Hand
Posts: 2458
 
gm shariff
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all.. for resolving and as well as guiding 'how to post'. sorry for inconvenience.

Thanks,
Sha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic