>         Hi,
>
>     Here is my problem. We are having in a lot of our webpages headlines.
> This is achieved by calling from JavaScript a servlet let's say
> HeadingServlet.
>  This servlet is very simple, it is reading something from a text file and
> passes
>  it to the client on every request (in doGet).I thought that moving this
> text file
>  reading in init method and read the content in a String ( very few lines)
> than
>  on every request just pass this String. I think it would be faster like
> this.
>     Once in a while (let's say once a day) we  change this text file with
an
> administrative
> servlet (AdminServlet). Now i would like to call somehow the
HeadingServlet
> destroy
> and force reinitializing on next request.
>     I even thought about modifying the HeadingServlet.class date time and
> the servlet engine
> (with autoreload classes option turned on)   will reload it. However i
found
> this option too tricky.
>    If somebody has some answers please let me know.
> I am using Apache+Jserv so i use JSDK20.
>
> Thank You,
>
Hi,

I would do this.

In the init method, read in the file as before. However create a File object
that points to that file
and use the getLastModifiedMethod to return the 'long' time. Store this as
an instance var.

Each time you want to send the text to the client, create a File object to
the file and compare
the getLastModified time with your original one. If the two don't match,
read in the file
again before posting. Take care to update the things you need to of course.

It may be that the File objects getLastModified time returned will be
updated via the OS
in which case you can save the extra File instantiations.

Andy Bailey

___________________________________________________________________________
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

Reply via email to