Login

mvnForum

mvnForum Homepage Welcome Guest
  Search  
  Index  | Recent Threads  | Unanswered Threads  | List Polls  | Public Albums  | Who's Online  | Help


Quick Go »


No member browsing this thread
Thread Status: Active
Total posts in this thread: 9
Post new Thread
Author
Previous Thread This topic has been viewed 1185 times and has 8 replies Next Thread
Female bulimic
Stranger




Joined: Apr 24, 2006
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Storing application & all changes in ServletContext

Hi All,
I am contemplating to write as below but have doubts.


public class Entry extends HttpServlet{
public void init(ServletConfig config)throws ServletException{
// Retrieve application(values) from db & store in ServletContext.
}

public void destroy(){
// Save application(values) to db.
}
}


All changes are reflected only in the application. Application(values) is only written back to database when it is closed. Pls. advise. Thank you.
[Apr 24, 2006 5:34:26 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male minhnn
mvnForum Developer
Member's Avatar

Vietnam
Joined: Oct 16, 2002
Post Count: 2956
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Yes, I think you can do it this way, and what is your problem that you cannot solved?
----------------------------------------
Minh Nguyen
mvnForum Developer
Want a free, open source Java Jsp/Servlet forum, get mvnForum at http://www.mvnForum.com

http://www.DienDanLinux.org
[Jul 9, 2006 9:30:25 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    http://www.MyVietnam.net    minhnn_mvn [Link] Report threatening or abusive post: please login first  Go to top 
Female bulimic
Stranger




Joined: Apr 24, 2006
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Did not encounter any problem with this(so far). Only not sure if this is a good idea. I thought it would lead to performance gain if there is not much database calls involved in an application. Is this true?
[Jul 9, 2006 4:41:53 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male tqphong
mvnForum developer



Vietnam
Joined: Sep 16, 2004
Post Count: 85
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Did not encounter any problem with this(so far). Only not sure if this is a good idea. I thought it would lead to performance gain if there is not much database calls involved in an application. Is this true?


I'm not sure I understand what you thought. However, init & destroy, each of them is called 1 times exactly by servlet container in your application, i don't think there are performance problems here.. confused
[Jul 10, 2006 10:19:47 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    minesking [Link] Report threatening or abusive post: please login first  Go to top 
Female bulimic
Stranger




Joined: Apr 24, 2006
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Let me try to clarify.

I come to this idea as I do not want to make many database calls. However, I am not sure if it is a good idea.

EntryServlet would retrieve all tables from the database & build the application & store in ServletContext in init(). Subsequent changes would only reflect in the application(not written to database). The application would only be written back to database in destroy().

So my question is, would it be more efficient if I write application in this manner? Secondly, is this a good practice?
[Jul 10, 2006 3:30:04 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male tqphong
mvnForum developer



Vietnam
Joined: Sep 16, 2004
Post Count: 85
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Let me try to clarify.

I come to this idea as I do not want to make many database calls. However, I am not sure if it is a good idea.

EntryServlet would retrieve all tables from the database & build the application & store in ServletContext in init(). Subsequent changes would only reflect in the application(not written to database). The application would only be written back to database in destroy().

So my question is, would it be more efficient if I write application in this manner? Secondly, is this a good practice?


It sound simirlar to "caching"
Let me give some my ideas,
- What happen if your application is crashed suddently. Because no time for server save all new memories-data back.
- System will be slow down because of have to remember data anytimes
- Server memories can not stand for a long time when the new data is added increasingly.

However, If you want to apply caching, you should consider system & application. you should applied this strategy for Configurable Data: username, password, row_per_page... which saving back is not important. This is the way most applications apply. smile
[Jul 11, 2006 2:45:41 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    minesking [Link] Report threatening or abusive post: please login first  Go to top 
Female bulimic
Stranger




Joined: Apr 24, 2006
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Thank you for the caution and suggestion. Will heed your advise.
System will be slow down because of have to remember data anytimes

Funny.. it is actually faster than other application which have to retrieve data from database. Is this because it is relatively small & therefore system could accomodate it well?
[Jul 12, 2006 9:19:29 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male tqphong
mvnForum developer



Vietnam
Joined: Sep 16, 2004
Post Count: 85
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Thank you for the caution and suggestion. Will heed your advise.
System will be slow down because of have to remember data anytimes

Funny.. it is actually faster than other application which have to retrieve data from database. Is this because it is relatively small & therefore system could accomodate it well?


Yes, that is what i thought. We can imagine that. In your desktop, some background application (relatively small) can run with no sense but what happen when you open a Java IDE.. eclipse.. (big application) your pc get slow down clearly.. sad However, there is no any big problem when you open a browser to a website (Connect occasionally).. smile
[Jul 12, 2006 11:32:45 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest    minesking [Link] Report threatening or abusive post: please login first  Go to top 
Female bulimic
Stranger




Joined: Apr 24, 2006
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Storing application & all changes in ServletContext

Appreciate your response. It is helpful. smile Thank you.
[Jul 12, 2006 4:14:15 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Show Printable Version of Thread  Post new Thread