Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General 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: 2907
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic