GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HttpSession doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HttpSession doubt" Watch "HttpSession doubt" New topic
Author

HttpSession doubt

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

Numbers of previous attemptes does not change after second attempt to call the servlet .Please suggest what is the problem with my servlet:--
Here is my servlet code :-
Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

your ctr variable is local, it's scope is the method only.
try to store it in the session:

if (session.isNew()) {
msg = "Hello new User";
session.setAttribute("counter",ctr);
}
else {
msg = "Welcome back";
ctr=(Integer)session.getAttribute("counter")+1;
session.setAttribute("counter",ctr);
}


SCJP 5, SCWCD 5, SCBCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSession doubt