RE: [Core] Setup globals per new session
-Original Message- From: Mark Kaye Thanks Danny. I've looked into this and it seems to be exactly what I'm looking for. You're a star. Hmm, it seems I can't use HttpSessionListener after all :(. After looking into it in more depth, it looks like I won't be able to get a handle to the HttpServletRequest that actually contains the information I need to key on i.e. the hostname, or at least the Request URI which I can parse. So, does anyone else have any ideas how to do this? To reiterate my problem briefly: I need to be able to populate the HttpSession with information as soon as the session is created, or at least before the HttpServletResponse is sent back. The information I use in order to decide what to populate the session with is the server hostname. So for instance: www.server1.com - Store clubName in session with value Reds. www.server2.com - Store clubName in session with value Blues. I need to do this so I could (for instance) welcome a visitor to server1.com with Welcome Reds. I've over simplified my requirement, but the above is the lowest common denominator. I have considered running each host in it's own context in Tomcat. But that's a nightmare in terms of memory bloat. This is how we are currently doing it with our non Struts based app. With just a few contexts the server is almost maxed on memory (2Gb RAM). I may have to put up with redirecting all new sessions to the index page, which I suppose is not too unreasonable, although a little unexpected for a user who has bookmarked or clicked on a deep link - but then this can be an issue with any web application. Any suggestions? Help, as always, much appreciated. Best, M -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [Core] Setup globals per new session
OK, I've decided to create an IndexAction and bind it to /index, then add welcome-fileindex.do/welcome-file to my web.xml. This appears to work and will allow me to set up all the session state I need dependant upon the hostname. I now have to figure out a clean mechanism to ensure that the client redirects to the index page if a session does not already exist. I am using Velocity/velstruts as my template engine to make content maintenance easy until we go to completely db driven content (whereupon I will still use Velocity but the content management is then taken away from the filesystem and so becomes a completely different problem). I can see two options and was wondering if you guys had a take on it: 1. Test for a token in every page and redirect to /index if the token is null. 2. Make all my content calls a *.do so that I can precede them all with an Action. I don't particularly like 1. as it contravenes MVC. I don't like 2 because it sounds like a lot of work :(. Anyone got any other suggestions? Cheers, M -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [Core] Setup globals per new session
About the first type, there is an example of tag in the struts example. It's named: CheckLogonTag / and I think it's useful. -Mensaje original- De: Mark Kaye [mailto:[EMAIL PROTECTED]] Enviado el: viernes, 30 de agosto de 2002 13:36 Para: Struts Users Mailing List Asunto: RE: [Core] Setup globals per new session OK, I've decided to create an IndexAction and bind it to /index, then add welcome-fileindex.do/welcome-file to my web.xml. This appears to work and will allow me to set up all the session state I need dependant upon the hostname. I now have to figure out a clean mechanism to ensure that the client redirects to the index page if a session does not already exist. I am using Velocity/velstruts as my template engine to make content maintenance easy until we go to completely db driven content (whereupon I will still use Velocity but the content management is then taken away from the filesystem and so becomes a completely different problem). I can see two options and was wondering if you guys had a take on it: 1. Test for a token in every page and redirect to /index if the token is null. 2. Make all my content calls a *.do so that I can precede them all with an Action. I don't particularly like 1. as it contravenes MVC. I don't like 2 because it sounds like a lot of work :(. Anyone got any other suggestions? Cheers, M -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [Core] Setup globals per new session
I assume you are using Struts (although there is no mention of it in your post). You could subclass the RequestProcessor and have the processPreprocess method check your request and setup the session for you. In Struts 1.1 the RequestProcessor intercepts all requests before they are dished off to actions. Using this strategy, you would have to ensure that all Views are processed through Actions to ensure your session is always setup before showing a view. Alternatively, you may be able to use a ServletFilter if you are using a Servlet 2.3 compliant container. I don't really have much experience with Filters (yet), but it seems this may be the sort of pre-processing they were designed for (although, I have not quite looked into what objects and methods you have access to from within a Filter). Using a Filter would keep your implementation Struts-neutral, but ties you to a newer Servlet spec for your app container. I hope this can at least get you started. Jason -Original Message- From: Mark Kaye [mailto:[EMAIL PROTECTED]] Sent: Friday, August 30, 2002 2:45 AM To: Struts Users Mailing List Subject: RE: [Core] Setup globals per new session -Original Message- From: Mark Kaye Thanks Danny. I've looked into this and it seems to be exactly what I'm looking for. You're a star. Hmm, it seems I can't use HttpSessionListener after all :(. After looking into it in more depth, it looks like I won't be able to get a handle to the HttpServletRequest that actually contains the information I need to key on i.e. the hostname, or at least the Request URI which I can parse. So, does anyone else have any ideas how to do this? To reiterate my problem briefly: I need to be able to populate the HttpSession with information as soon as the session is created, or at least before the HttpServletResponse is sent back. The information I use in order to decide what to populate the session with is the server hostname. So for instance: www.server1.com - Store clubName in session with value Reds. www.server2.com - Store clubName in session with value Blues. I need to do this so I could (for instance) welcome a visitor to server1.com with Welcome Reds. I've over simplified my requirement, but the above is the lowest common denominator. I have considered running each host in it's own context in Tomcat. But that's a nightmare in terms of memory bloat. This is how we are currently doing it with our non Struts based app. With just a few contexts the server is almost maxed on memory (2Gb RAM). I may have to put up with redirecting all new sessions to the index page, which I suppose is not too unreasonable, although a little unexpected for a user who has bookmarked or clicked on a deep link - but then this can be an issue with any web application. Any suggestions? Help, as always, much appreciated. Best, M -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE:[Core] Setup globals per new session
-Original Message- From: Trieu, Danny [mailto:[EMAIL PROTECTED]] Implement the HttpSessionListener Thanks Danny. I've looked into this and it seems to be exactly what I'm looking for. You're a star. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]