• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling Exceptions

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,
I am using using Struts1.1 to develop a webapplication. I am using sessions.
My problem is if I did not perform any operation in the applicaition for a certain period of time session automatically expires and give the following error.

" org.apache.jasper.JasperException"

I want my application to login page whenever this exception occurs.
How do I handle this in struts-config.xml with <global-exceptions>

I have written it like this
<global-exceptions>
<exception key="error.required" type="org.apache.jasper.JasperException"
path="/login.jsp" />
</global-exceptions>

Help me in this regard.

Thanks in advance.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could have your actions check for a valid session and if none is present send user to logout, a global forward that will send them to the login page.
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Mark, except that I think the code to check for the session should be put in an intercepting filter. That way, you only need to write the session checking code in one place, rather than in every Action.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Filter would work... except for in the most recent version of WSAD (for anyone out there using it) which has some strange bug where filters don't use the same session as everything else. In any other environment it's a great option.

Checking session in every Action that needs it might not be that bad of solution if not all Actions need it. If they DO, then the filter is certainly a good solution. It's not that much code.
if(session==null)goCrazyNuts();
 
pavanasree vasireddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I don't know how to use filters.

Is there any way of handling it. can you please tell me where I am going wrong while handling the Exception through <global-exceptions> option in stuts-config.xml.

It would be great if you me help out in this with out filters.

Thank you
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a word of warning - have a look at a previous post of mine regarding timed out session's not returning null!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic