User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 422,635 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,679 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1449 | Replies: 2
Reply
Join Date: Dec 2007
Posts: 11
Reputation: shweta797 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shweta797 shweta797 is offline Offline
Newbie Poster

send session variable in an array

  #1  
Feb 5th, 2008
Hi
I want to send session variable in an array from one JSP page to another using code
given below
String[] textfield_a =(String[])session.getAttribute("textfield_a");
But i m getting error .
plz help
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 5
Reputation: kalyankalyan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
kalyankalyan kalyankalyan is offline Offline
Newbie Poster

Re: send session variable in an array

  #2  
Feb 5th, 2008
Can you plese be clear in ur requirement.
Atleast can u send me the code snippet,


Originally Posted by shweta797 View Post
Hi
I want to send session variable in an array from one JSP page to another using code
given below
String[] textfield_a =(String[])session.getAttribute("textfield_a");
But i m getting error .
plz help
Reply With Quote  
Join Date: Jan 2008
Posts: 35
Reputation: electron33 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
electron33 electron33 is offline Offline
Light Poster

Solution Re: send session variable in an array

  #3  
Feb 5th, 2008
You can't cast to String[]. It does not exist in Java.

Try to use an ArrayList instead.

All JSP pages share the same session. You will always have the variable in session until the session is terminated or until you remove the attribute yourself.

When you want the values back into another page you could use some code like this.
ArrayList list = (ArrayList) session.getAttribute("callername");

Now you have the values in the list. on the second page

Now you can get the value with following code.
<%
Iterator iter = list.iterator();
while(iter.hasNext()){
%>
<input type="text" name="textfield1" value="<%= String.valueOf(iter.next()) %>">
<%
}
%>
Last edited by electron33 : Feb 5th, 2008 at 3:40 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 3:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC