*
The moose likes JSP and the fly likes How to retrieve sessions variables in JSP   Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to retrieve sessions variables in JSP   " Watch "How to retrieve sessions variables in JSP   " New topic
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: 2902
    
    1

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
Crossposted at the Sun forum: http://forums.sun.com/thread.jspa?threadID=5370690
Please read this: http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retrieve sessions variables in JSP