Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

users data is mixing in servlet

 
sravanthi paleti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,

I checked it and the problem is solved.

Thanks,
Saravnthi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic