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 instance and tomcat  RSS feed

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a bit confuse now with how servlet works.

is there only one servlet instance?

I don't see any differences between static variable and class variable?

Other thing, how to "refresh" tomcat?
Every time I re-compile and deploy the class, I need to restart Tomcat so it will reload the new one.

thanks all
Tony
 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, to make the 1st question a bit clear.

I create a simple servlet with counter variable (I try static, static private and class scope) and just display it.

If I open 2 browser windows and invoke the same servlet, I wish each browser show each own counter like in standard Java program.

thanks again
tony
 
Dicky Bullin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,

I have an example for your question.
Here's that:



When you want to put a variable that specific to a user (user-scope). You may put it to the session. The Class Variable is for common used that shared for all the client that request the page.


If you're using Tomcat5.xx, the Tomcat has ability to Deploy the Web Application without restarting the server. You may refer to the Tomcat 5 Documentation, section Tomcat Manager.


Regards,
Dicky Bullin
[ August 18, 2004: Message edited by: Dicky Bullin ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!