wood burning stoves 2.0*
The moose likes Servlets and the fly likes Clear servlet thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Clear servlet thread" Watch "Clear servlet thread" New topic
Author

Clear servlet thread

Dan Parsons
Ranch Hand

Joined: May 30, 2007
Posts: 70
I would like to initialize a Servlet when it is called.
Will this clear any sessions and threads?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Completely unnecessary. What are you actually trying to accomplish?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dan Parsons
Ranch Hand

Joined: May 30, 2007
Posts: 70
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

Joined: Jan 10, 2002
Posts: 60794
    
  65

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

 
Don't get me started about those stupid light bulbs.
 
subject: Clear servlet thread
 
Similar Threads
JSTL c:forEach tag iteration variable
nested for loop
Delegating to doGet()
calling sub class' method from super class
Why does GenericServlet implement ServletConfig