Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clear servlet thread

 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to initialize a Servlet when it is called.
Will this clear any sessions and threads?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Completely unnecessary. What are you actually trying to accomplish?
 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Servlet as a controller for my form entries.

If I send them to the Servlet with or without sessions it wont show anything after the servlet forwards to a JSP. I am encoding with sun.misc.BASE64Encoder in another Servlet and it seems to be effecting all my Servlets for this webapp. If I take out the sun.misc.BASE64Encoder in the other servlet, the form entries will work in my servlet and show up in the forwarded jsp. I was hoping to somehow clear or eliminate any threads that were created from another Servlet in my webapp that has the sun.misc.BASE64Encoder.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what's up with all the Base64 encoding (perhaps you can explain that), but there's no such thing as left-over threads that could be affecting other servlet invocations, and therefore need "resetting".

Let's back up a bit, explain why you are Base64 encoding stuff (really? why?), and what makes you think that it's affecting other threads.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Parsons wrote:I am encoding with sun.misc.BASE64Encoder [...]

I never recommend using internal libraries--they're not guaranteed to be present in any JRE.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to initialize a Servlet when it is called.


When the init() method is called by the servlet container, this is guaranteed to be before any request has been sent to the servlet so there is no concept of a current request and thus a current session.

Any sessions associated with the web applications would have to be left over from the last time the application was running. The only way they would be used is if the client browser still has a cookie for the sessionid and the session has not been timed out.

Bill

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic