Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 14th, 2003, 04:15 PM
brenthamby brenthamby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 28 brenthamby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Extending Struts Action Class to handle timeouts

I am using Struts 1.0.2 and I want to put my session timeout code in one place. I am thinking of extending the Action class to do this. But I am not sure if I should override the perform method. If I do I have to return an ActionForward object...

Any thoughts?

Reply With Quote
  #2  
Old March 15th, 2003, 06:20 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
If you want to have one central place that everyone can get authorized at, one way would indeed be to extend the action class. What you could do is something like this:
Code:
abstract class MyAction extends Action {
  public ActionForward perform(ActionMapping mapping,
     ActionForm form, javax.servlet.http.HttpServletRequest request,
     javax.servlet.http.HttpServletResponse response) {
    ...do some authentication code...
    return myPerform(mapping, form, request, response);
  }
  abstract ActionForward myPerform(ActionMapping mapping,
     ActionForm form, javax.servlet.http.HttpServletRequest request,
     javax.servlet.http.HttpServletResponse response) {
    ..use this as a normal perform method...
  }
}


Then, when your code extends MyAction it would implement the myPerform method instead of perform. The ActionServlet will call the perform of MyAction, which will in turn call the myPerform method of the action that extends MyPerform. Hope that made sense.

Reply With Quote
  #3  
Old March 17th, 2003, 11:55 AM
brenthamby brenthamby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 28 brenthamby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks

Exactly! Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Extending Struts Action Class to handle timeouts


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT