|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
thanks
Exactly! Thanks!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Extending Struts Action Class to handle timeouts |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|