File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

users data is mixing in servlet

sravanthi paleti

Joined: Jun 18, 2001
Posts: 4
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?
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

Joined: Mar 22, 2000
Posts: 13037
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.

author of:
sravanthi paleti

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

I checked it and the problem is solved.

I agree. Here's the link:
subject: users data is mixing in servlet
jQuery in Action, 3rd edition