I would not do so - A servlet is meant for processing a request and send
a response. That's the only specified behavior that the container
expects from a servlet.
I'm not going to disprove about your applications working or not. It all
depends on what resources you're using during these threads. As long as
you don't use any resources maintained by the container
(request/response objects, session objects, context etc.), you're safe.
This is because, all these resources are not guaranteed to be available
outside the context of a request. Things might still work - but you can
not guarantee in a production environment.
Keeping the original intent of servlets in mind- I would not implement
such things. The rest is a matter of choice.
Just on the lighter side - I've heard of a story where a team struggled
to figure out why their app server (hosting servlets) is crashing. They
could not find any clue from the server logs. Finally, they figured out
that some of the servlets have System.exit() statements during exception
handling! What do we conclude from this?
Cheers.
Rajesh Nair wrote:
>
> This is wrong. Why do you say this? I agree with the part on the
> servlet engine
> controlling servlet instantiating and unloading among other things.
> Whatever threads the
> servlet container uses is used for the servlet management. If the
> container
> uses a thread to handle a doGet request, how can it be guaranteed that
> what the programmer
> does in that doGet request doesn' t need a thread? No such assumptions
> can be made.
> In fact, in one of my applications I had to use threads in managing my
> needs and they worked
> perfectly. Using or not using threads is, according to me, an
> implementation issue.
>
>
> >I do not know why you want to create a thread in your servlet. A
> servlet
> >container is a controlled runtime with the container managing
> >instantitiaion and threads for requests. Explicit threading may
> conflict
> >with the container.
>
> >I suggest that you've a relook at your design. Your design does not
> seem
> >to be sensitive to the specification.
> >
> >> in a method in the controller servlet calling it from the thread's
> run()
> >> implemantation.
> >>
> >> Now my problem is to invalidate the session the for the logged out
> user(
> >one
> >> session allowed per user) using the sessionid stored in the second
> >> hashtable at the time of getting the session.
> >
> >You should use the <get/set>MaxInactiveInterval of HttpSession to let
> >the container invalidate the sessions for you.
> >
> >Hopefully, by changing the design, you'll not have the above
> >requirement.
> >
> >Cheers!
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources:
> http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >______________________________________________
> >FREE Personalized Email at Mail.com
> >Sign up at http://www.mail.com/?sr=signup
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources:
> http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
> Rajesh Nair
> [EMAIL PROTECTED]
> Ph: 913 599 7201
> ----------------------------------------------------------------------
> R&D
> Informix Software
--
*****************************************************************
Who are YOU?' said the Caterpillar.
This was not an encouraging opening for a conversation. Alice replied,
rather shyly, `I--I hardly know, sir, just at present-- at least I know
who I WAS when I got up this morning, but I think I must have been
changed several times since then.'
`What do you mean by that?' said the Caterpillar sternly. `Explain
yourself!'
`I can't explain MYSELF, I'm afraid, sir' said Alice, `because I'm not
myself, you see.'
*****************************************************************
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html