The above scenario only works for a single JSP. If you want code that executes before any JSP or action is executed, you should look at writing a Servlet Filter. This is only available if your Application server supports J2EE 1.4 or above (Tomcat 5). See chapter 11 of the Sun J2EE Tutorial
The session is normally maintained by session cookies. If you close your browser you lose the cookie. If you have disabled cookies on your machine then it also might not work. In cases such as that you should be using the method response.encodeURL() to maintain the session for you in any hyperlinks you produce. Struts normally handles that for you though if necessary.
How about using a custom request processor to solve your purpose? Override the processPreprocess which performs session handling and that can be used for all the requests.
Ajay's solution would work well at performing logic before any action is executed. However, it would not work at performing logic before a JSP is dispalyed. If the user enters a URL such as http://myserver/myapp/mypage.jsp, the request processor is never invoked.