View Single Post
Old 06-16-2005, 05:31 AM   #1 (permalink)
edwardmraj
Registered User
 
Join Date: Jun 2005
Posts: 3
edwardmraj is on a distinguished road
How to Nullifying the Arraylist Object?..

hi all

How to Nullifying the ArrayList Object in JSP .

For Eg.

I declared an ArrayList as below in the Code. Beacause i am going to add an object in to Arraylist using while loop.

-------JSP File Code ---------------
<! ArrayList alTest = new ArrayList(); >

while(condition)
{

<jsp:usebean id="test" class="com.beanclass" scope="request">
<jsp:setproperty name="test" property="strCCNO1" param="textCCNo1"/>
<jsp:setproperty name="test" property="strCCNO2" param="textCCNo2"/>
<jsp:setproperty name="test" property="strCCNO3" param="textCCNo3"/>
</jsp:usebean>

<%
alTest.add(test); //Object of the Bean
%>

<%
request.setAttribute("lis","alTest");
}
%>

<jsp:forward page="servlet" />

---------------------End Code----------------

Thro refreshing the page i'm entering the value in the textboxs and setting the values using methods in <jsp:usebean> . Then i am adding the usebean object to arraylist.

it working fine . no problem.....

Here the Arraylist declared as global<%! Arraylist al= new ArrayList()%>, so what's happening , if more than one user try to access the page and do the same thing, that's also added in the same arraylist object.


Also when i try to declare that AL as in local ie <% Arraylist al= new ArrayList()%> it's every time refresh and create new object. so i con't store that bean objects in loop.



So How to solve this problem???? Is possible to have the arraylist as global and acheive this task? or else

If any one give the solution for this really it will help me lot!!

Thanks in Advance......

EDward
edwardmraj is offline   Reply With Quote