aspose file tools*
The moose likes Servlets and the fly likes users data is mixing in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "users data is mixing in servlet" Watch "users data is mixing in servlet" New topic
Author

users data is mixing in servlet

sravanthi paleti
Greenhorn

Joined: Jun 18, 2001
Posts: 4
Hi,
When my jsp page was hit by 10 people at a time,I got an error
message for one person with anothers data.
Let me explain you clearly,
'A' and ' B' are two persons.
A is getting a message "unable to submit with this "userID". "
But the userID 'A' got is entered by 'B'
Do I need to write a session in my servlet? If yes how can I write a session?
Thanks,
Sravanthi
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Servlets, by default, are multi-threaded.

So if you have placed any userID's, or other such data into a 'global' (to the servlet) variable, you can get this kind of problem.

Investigate the SingleThreadModel in the API (under "all classes")
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
You have undoubtedly used one or more instance variables to hold user data - this results in exactly what you have seen. You will have to do something to keep the various users data separate - sessions are provided by the API for this function.
Probably the servlet/JSP engine you are using came with some sample applications - search the source code for HttpSession usage.
Any book on servlets and JSP will cover this.
Bill

------------------
author of:
sravanthi paleti
Greenhorn

Joined: Jun 18, 2001
Posts: 4
Hi Mike,

I checked it and the problem is solved.

Thanks,
Saravnthi.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: users data is mixing in servlet