I have a question sounds like interesting: Say you have a web sites containing several applications App1, App2, App3. We need App1 session time out 20 minutes, App2 time out 40 minutes, and App3 time out 5 minutes. Is there a way even possible to do it?
Maybe I was not clear, I meant that all apps just is under one website and they just have one shared web.xml. Or put this way, you have a web application app1, then you put a link on app1 linking to app2, and you put another link on app1 to link to app3, but all these app1, app2 and app3 are just one web application. In this case can we still define the session time out for each of app1,app2,app3?
If they are part of the same war then they are not considered to be separate web applications. They are just different parts of the same web application.
Regardless, if your needs aren't met by configuration in the web.xml you can always set session timeout programatically by calling HttpSession.setMaxInactiveInterval(). It takes timeout value in terms of seconds (versus web.xml which is in terms of minutes).
To comment Chris Mathews's suggestion to use HttpSession.setMaxInactiveInterval(). This is not OK because this sets all the session to be the same time out. So I still need a way to set time out for different part of the same web application. I thought if there is a way to set session object time out, maybe it solves the issue. We can set all session objects in app1 to 20 minutes and 40 for those session objects in app2 and 5 for those session objects in app3, but this sounds crazy, not sure even there is a way to set the time out for a session object.
Originally posted by Larry Zhang: This is not OK because this sets all the session to be the same time out. So I still need a way to set time out for different part of the same web application. I thought if there is a way to set session object time out, maybe it solves the issue. We can set all session objects in app1 to 20 minutes and 40 for those session objects in app2 and 5 for those session objects in app3, but this sounds crazy, not sure even there is a way to set the time out for a session object.
What you are suggesting is not technically possible or logically feasible. The HttpSession shared across all of your "apps" since everything is part of a single web application. Therefore, if you set the timeout for one "app" then, by definition, it will be set for all "apps" in that web application.
What you seem to want is separate HttpSessions for each "app". This can only be achieved by properly separating out your "apps" into separate web applications.
Maybe your suggestion is the only way to achieve my goals. In doing so ( separating these apps into different ones ), do I need to separate the codes such as framework, utilities into different applications? If I do, I think the solution is not practical. Do we have a way to write a separate web.xml for separate part of web apps? Thanks Chris.
You wouldn't separate the framework and utilities into separate wars but you would separate them into separate jars. These jars would then be reused by each of your web applications.
What about that solution is not practical? It is a common practice, in fact it is a best practice. How else do you manage reusable code throughout an organization? If you say "cut and paste" I am going to go to wherever you are and slap you... [ June 10, 2004: Message edited by: Chris Mathews ]
First of all, all my framework and utilities classes will be compiled and put into Web Content/WEB-INF/classes - this is a WebSphere setting. These framework and utilities are frequently changed due to enhancement, it is not convenient to put them into jars. An addition issue, we are using App1 as a starting point and set session objects here and we want these session objects to be available in App2 and App3. If we separate App3 to be a different .war, it is easy for session objects set in App1 to be available in App3?
Simply put, think about App1 sets "user" session object, App2(very private data like salary display pages) needs session time out 5 minutes, but App2 ( having a very long text field filling page, taking 2 hours to finish typing) needs an 1 hour time out. Both App1 and App2 need "user" session object. However, we need a different time out.
I have read all the above long conversation.. i feel there should be one Web Application (as it is running/designed) containing 3 sub modules named App1, App2 & App3. For handling timeout session.setMaxInactiveInterval(<duration_in_sec> .... should be the best possible solution which can be employed..... and <duration_in_sec> should vary according to the sub module. i.e. for App1 it should be session.setmaxInactiveInterval(20*60), for App2 (40*60) and for App3 (5*60)...
Rishi Tandon<br />SCJP 1.2<br />SCBCD
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop