Hi!

In general it would be a good idea if you had the data in the ServletContext as
that is basically a HashMap and therefore very fast. BUT... ServletContext are
local to your instance of the servlet engine and not distributable. i.e. if you
have to scale the appication to multiple machines you should think about using
Session for you user specific data and maybe using a database or an EJB server for
you apllication specific data.

Another issue with ServletContexts is that there is currently no way to notify the
ServletContext that the application is shut down. Therefore you need to overwrite a
Servlet's destroy method if you want write your data back to a file or database
when the app is shut down.

Also note that if you servers crashes all unsaved data in the ServletContext is
lost.

Hope this answers your question.

-hendrik
- - - - - - - - - - - - - - - - - - - - - - - - - - -
  tagtraum industries      http://www.tagtraum.com/
  jo!                 small&smart 2.2 servletengine
  Java Server & Servlets   The web-application book
  The WebApp Framework        http://www.webapp.de/


Soon Hong wrote:

> hello,
>
> I have a performance question regarding the storing of
> information.
>
> I have data that needs to be frequently accessed and
> modified by users, and do not know if i should attach
> it to the servletcontext or if i can simply access it
> every time from the database.
>
> i would rather leave the information in the database
> but do not know if this would cause extra overhead.
>
> is it better to attach data to the servletcontext? is
> there a major performance difference?
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail � Free email you can access from anywhere!
> http://mail.yahoo.com/
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to