Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet requests interfere with each other  RSS feed

 
Luis Perdigao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I did a Servlet and a JSP with a combobox. I called the JSP on one browser and selected value n1 from the combobox.
From another computer, I called the (same URL) and selected value n2. I expected the Servlet to handled both requests seperately, however when I select value n2 on the 2nd browser, the jsp on the 1st browser that initially had value 1, now changes into value 2 as well.

Can anyone explain me what is going on? Why cant the servlet handle requests seperately? users actions on different browsers should not interfer with each other..!

Thank you in advance and best regards
Luis
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Separate requests should indeed not interfere, but it's perfectly possible to write a servlet in such way that they will interfere - it can happen if the servlet is not thread-safe.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also please read HtmlHasNoComboBox -- using correct terms is an important part of developing.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us your JSP and servlet code? Please keep the listing simple and concise.
 
mak pandian
Ranch Hand
Posts: 30
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is possible if and if only you implement SingleThreadModel in your servlet class.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is possible if and if only you implement SingleThreadModel in your servlet class.

Actually, using STM was meant to prevent concurrency issues like these (maybe I'm misunderstanding what you're trying to say). But regardless, STM does not actually prevent concurrency issues, and destroys concurrency - don't ever use it. It should have been removed from the Servlet API years ago.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!