Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is the value the same?

Status
Not open for further replies.

lowbk

Technical User
Nov 26, 2001
162
SG
suppose i have a servlet that looks like the one below. i set a hashtable to be accessible by all the methods in the servlet. when user enters servlet, he goes into step1 and some values will be added to hashtable and then forward to jsp1. at jsp1, he clicks a button and it sends him back to the same servlet and goes into step2 and then send the hashtable to jsp2.

my question is, when the user goes into jsp2, are the values in hashtable added during step1 still the same or will the hashtable be reinitialised due to the new hashtable()?

Code:
public class testServlet
{
[b]hashtable ht=new hashtable();[/b]

public void doPost()
{
   if(step1)
   {
   .... add something to ht
    request.setAttribute( hashtable ,ht);
    forward to jsp1
   }
   else if(step2)
   {
    .... did not touch ht
    request.setAttribute( hashtable ,ht);
    forward to jsp2
   }
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top