This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 13000
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: users data is mixing in servlet
It's not a secret anymore!