Author
How to retrieve sessions variables in JSP
gm shariff
Greenhorn
Joined: Nov 26, 2007
Posts: 5
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
Joined: Feb 19, 2008
Posts: 2896
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 !
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted Mar 02, 2009 08:52:53
0
Crossposted at the Sun forum: http://forums.sun.com/thread.jspa?threadID=5370690
Please read this: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
gm shariff
Greenhorn
Joined: Nov 26, 2007
Posts: 5
thank you all.. for resolving and as well as guiding 'how to post'. sorry for inconvenience.
Thanks,
Sha
subject: How to retrieve sessions variables in JSP