----- Original Message -----
Sent: Wednesday, August 11, 1999 10:19
AM
Subject: Require information
Hi all,
I am a new comer to
"SERVLETS".
Presently I am facing these problems
:
1.Once my instance of servlet is instantiated,
the servlet needs to take some further input from the Browser. Hence I want
the servlet to wait for the input. How do I achieve it?
2. I want to retain some
information (in the form of structures) so that the next instance of the
servlet can be called with these retained values. At present I am unable to do
that because once the servlet instance expires I lose the data
too.
3. Can we use applets to call the servlets, so that we can
offload the screen validations to the applet and use the servlet merely to
perform server side processing.
Pls guide me in these regards.
Thanks in advance,
Vijayanand
Hi,
Sequence is this,
Servlet is loaded by servlet engine its init
method is called. The servlet then sits there waiting for a client
request OR for its destroy method to be called.
The servlet will sit there waiting until an
valid request comes to it (PUT, GET, POST, DELETE method). What actually
happens is that the servlets
service method is called, if you don't
override this method the default method will determine which of the doGet,
doPost, doPut or doDelete methods
are to be called and calls them with the
correct parameters (HttpServletRequest and
HttpServletResponse objects). Once the
service method call is complete
the servlet then sits there waiting for the next
request OR
its destroy() method is called. This you can
override to perform cleanup like closing and disposing of DB connections,
wrapping up ConnectionPools, closing
files etc.
Destroy is only ever called once as is
init.
You can use the session object to store data in
them. The session object is a persistent hashtable like object that can store
things between client requests in a session. I recommend you read some of the
literature on the internet and/or buy Jason Hunter's book Servlet Programming
in Java (a must for beginners).
Yes you can use applets to read from and write to
servlets. Again details on how this can be done are to be found in Jason's
book.
Hope this clears things up for you
Andy Bailey
PS Jason, if you read this when do I get my cut
for touting your book :)