> 2. For that i 've used HttpSession class object.The
> object is used to check session timeout.
> but the problem is I ve to check this on each page
> and the same code has to be put in every page.
You really can't avoid it, especially if you are checking the timeout on
the client side as you seem to be implying. There is no way for the
servlet to indicate to the browser that it needs to run some common method
for each page. You will need to put the code into each page.
However, if you want the session checking code to be on each html page
returned by the servlet, you could put the common code into a file, and
then include that file each time you process a request. With this
technique, you have to put the include directive into each page, but
that's a lot less than duplicating the entire block of code.
You could choose to check the session on the server side. In that case,
you could encapsulate the timeout checking code into a class. Then have
all requests go to a single servlet that checks the session status, and
then forwards to the appropriate servlet for actual handling of the
request.
I believe that most web applications use the latter approach. Session
timeout is checked on the server side, not on each page on the client side.
Kevin Mukhar
Beginning Java Databases
Oracle 9i Java Programming
Oracle 8i Application Programming