Re: Subclassing ActionForward

2005-05-18 Thread James Mitchell
LOL...about 3 minutes with Textpad and it's wonderful block select (Alt + 
mouse drag).


--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]

- Original Message - 
From: "Benedict, Paul C" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" 
Sent: Wednesday, May 18, 2005 4:11 PM
Subject: RE: Subclassing ActionForward


How long did it take to do your nice UML graph in ASCII? :)
-Original Message-
From: James Mitchell [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 18, 2005 3:02 PM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: Subclassing ActionForward
In your BaseDispatchAction override the execute() method, and in that, if
everything checks out (session expiration, authentication, authorization,
etc, etc) then simply super.execute().
 DispatchActionMyBaseDispAct  CustomerAction
 |   |  |
--- execute() --->|. |
 |   || |
 |   | (if session ok)  |
 |   || |
 |<--super.execute()--' |
 |   |  |
 |--- foo() --->|
 |   |  |
 |   |  |
--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]

- Original Message - 
From: "Lee Harrington" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Wednesday, May 18, 2005 1:47 PM
Subject: Re: Subclassing ActionForward

I'm all for doing things "the struts way".
What I don't see in your example is WHERE to either throw the
exception or call the global forward.  I'm trying to avoid putting
this in all my actions (btw, I use dispatch actions).
I did have the foresight to subclass the dispatchAction class:
public class BaseDispatchAction extends DispatchAction {
/**
*
*/
public BaseDispatchAction() {
super();
}
public static void main(String[] args) {
}
}
I just don't see where I have access to my "struts goodies" like
request, mapping etc.
Sorry to be so dull.
Lee
On 5/18/05, James Mitchell <[EMAIL PROTECTED]> wrote:
I do not recommend using a filter.  You are much better off using what
you've already invested your time in (Struts).
By using a base action as a single point of entry into your Actions, you
can
do this check in one place, and reuse any resources already handed to you
in
your base action.
You could:
a) forward to some global forward
For example:

  
...(removed for brevity)...

b) throw an exception that you've globally configured
   Struts to handle (declarative exception handling)
With b you now have a declarative way to handle an expired
sessions and you have full access to your resource bundle.
With either approach, you don't have to worry about whether your app is
the
root application (http://www.myapp.com/), or nested either by
configuration
or using Modules (http://www.myapp.com/go/here/for/my/app/), all cases 
are
handled.

With a filter, you would basically have to hard code where your app goes.
For example:
 - /foo.jsp
 (single jsp to display some friendly error message)
 - /NonStruts/SessionExpiredCustomServlet
 (custom servlet for dealing with sessions)
 - /SessionExpired.do
 (forward to Struts anyway.bad idea)
Sure, you could get foo.jsp (from above) as a context-param, but I like 
to
keep my work in one place, the struts-config.xml file.

--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]
- Original Message -----
From: "Lee Harrington" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Wednesday, May 18, 2005 12:07 PM
Subject: Re: Subclassing ActionForward
Okhave a filter...it runs (use logging to determine this).
I'm stuck on how to forward to the login page.
Here's my filter code:
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
try {
chain.doFilter(request, response);
//
// Ensure there is a user in the session
//
UserDTO user = (UserDTO) request.getSession().getAttribute("user");
if (user==null) {
// User is not logged in, redirect to login page
// How do I do that?
}
} finally {
}
}
TIA,
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional 

RE: Subclassing ActionForward

2005-05-18 Thread Benedict, Paul C
How long did it take to do your nice UML graph in ASCII? :)

-Original Message-
From: James Mitchell [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 18, 2005 3:02 PM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: Subclassing ActionForward


In your BaseDispatchAction override the execute() method, and in that, if 
everything checks out (session expiration, authentication, authorization, 
etc, etc) then simply super.execute().

  DispatchActionMyBaseDispAct  CustomerAction
  |   |  |
--- execute() --->|. |
  |   || |
  |   | (if session ok)  |
  |   || |
  |<--super.execute()--' |
  |   |  |
  |--- foo() --->|
  |   |  |
  |   |  |


--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]




- Original Message - 
From: "Lee Harrington" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Wednesday, May 18, 2005 1:47 PM
Subject: Re: Subclassing ActionForward


I'm all for doing things "the struts way".

What I don't see in your example is WHERE to either throw the
exception or call the global forward.  I'm trying to avoid putting
this in all my actions (btw, I use dispatch actions).

I did have the foresight to subclass the dispatchAction class:

public class BaseDispatchAction extends DispatchAction {

/**
*
*/
public BaseDispatchAction() {
super();

}

public static void main(String[] args) {
}
}

I just don't see where I have access to my "struts goodies" like
request, mapping etc.

Sorry to be so dull.

Lee

On 5/18/05, James Mitchell <[EMAIL PROTECTED]> wrote:
> I do not recommend using a filter.  You are much better off using what
> you've already invested your time in (Struts).
>
> By using a base action as a single point of entry into your Actions, you 
> can
> do this check in one place, and reuse any resources already handed to you 
> in
> your base action.
>
> You could:
> a) forward to some global forward
>
> For example:
>
> 
>   
> ...(removed for brevity)...
> 
>
> b) throw an exception that you've globally configured
>Struts to handle (declarative exception handling)
>
> With b you now have a declarative way to handle an expired
> sessions and you have full access to your resource bundle.
>
> With either approach, you don't have to worry about whether your app is 
> the
> root application (http://www.myapp.com/), or nested either by 
> configuration
> or using Modules (http://www.myapp.com/go/here/for/my/app/), all cases are
> handled.
>
> With a filter, you would basically have to hard code where your app goes.
> For example:
>  - /foo.jsp
>  (single jsp to display some friendly error message)
>
>  - /NonStruts/SessionExpiredCustomServlet
>  (custom servlet for dealing with sessions)
>
>  - /SessionExpired.do
>  (forward to Struts anyway.bad idea)
>
> Sure, you could get foo.jsp (from above) as a context-param, but I like to
> keep my work in one place, the struts-config.xml file.
>
> --
> James Mitchell
> Software Engineer / Open Source Evangelist
> Consulting / Mentoring / Freelance
> EdgeTech, Inc.
> http://www.edgetechservices.net/
> 678.910.8017
> AIM:   jmitchtx
> Yahoo: jmitchtx
> MSN:   [EMAIL PROTECTED]
>
>
> - Original Message -
> From: "Lee Harrington" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" 
> Sent: Wednesday, May 18, 2005 12:07 PM
> Subject: Re: Subclassing ActionForward
>
> Okhave a filter...it runs (use logging to determine this).
>
> I'm stuck on how to forward to the login page.
>
> Here's my filter code:
>
> public void doFilter(ServletRequest request,
> ServletResponse response,
> FilterChain chain)
> throws IOException, ServletException {
>
> try {
> chain.doFilter(request, response);
> //
> // Ensure there is a user in the session
> //
> UserDTO user = (UserDTO) request.getSession().getAttribute("user");
> if (user==null) {
> // User is not logged in, redirect to login page
> // How do I do that?
> }
>
> } finally {
> }
> }
>
> TIA,
>
> Lee
>
> 

Re: Subclassing ActionForward

2005-05-18 Thread James Mitchell
In your BaseDispatchAction override the execute() method, and in that, if 
everything checks out (session expiration, authentication, authorization, 
etc, etc) then simply super.execute().

 DispatchActionMyBaseDispAct  CustomerAction
 |   |  |
--- execute() --->|. |
 |   || |
 |   | (if session ok)  |
 |   || |
 |<--super.execute()--' |
 |   |  |
 |--- foo() --->|
 |   |  |
 |   |  |
--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]

- Original Message - 
From: "Lee Harrington" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Wednesday, May 18, 2005 1:47 PM
Subject: Re: Subclassing ActionForward

I'm all for doing things "the struts way".
What I don't see in your example is WHERE to either throw the
exception or call the global forward.  I'm trying to avoid putting
this in all my actions (btw, I use dispatch actions).
I did have the foresight to subclass the dispatchAction class:
public class BaseDispatchAction extends DispatchAction {
/**
*
*/
public BaseDispatchAction() {
super();
}
public static void main(String[] args) {
}
}
I just don't see where I have access to my "struts goodies" like
request, mapping etc.
Sorry to be so dull.
Lee
On 5/18/05, James Mitchell <[EMAIL PROTECTED]> wrote:
I do not recommend using a filter.  You are much better off using what
you've already invested your time in (Struts).
By using a base action as a single point of entry into your Actions, you 
can
do this check in one place, and reuse any resources already handed to you 
in
your base action.

You could:
a) forward to some global forward
For example:

  
...(removed for brevity)...

b) throw an exception that you've globally configured
   Struts to handle (declarative exception handling)
With b you now have a declarative way to handle an expired
sessions and you have full access to your resource bundle.
With either approach, you don't have to worry about whether your app is 
the
root application (http://www.myapp.com/), or nested either by 
configuration
or using Modules (http://www.myapp.com/go/here/for/my/app/), all cases are
handled.

With a filter, you would basically have to hard code where your app goes.
For example:
 - /foo.jsp
 (single jsp to display some friendly error message)
 - /NonStruts/SessionExpiredCustomServlet
 (custom servlet for dealing with sessions)
 - /SessionExpired.do
 (forward to Struts anyway.bad idea)
Sure, you could get foo.jsp (from above) as a context-param, but I like to
keep my work in one place, the struts-config.xml file.
--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]
- Original Message -
From: "Lee Harrington" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Wednesday, May 18, 2005 12:07 PM
Subject: Re: Subclassing ActionForward
Okhave a filter...it runs (use logging to determine this).
I'm stuck on how to forward to the login page.
Here's my filter code:
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
try {
chain.doFilter(request, response);
//
// Ensure there is a user in the session
//
UserDTO user = (UserDTO) request.getSession().getAttribute("user");
if (user==null) {
// User is not logged in, redirect to login page
// How do I do that?
}
} finally {
}
}
TIA,
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-18 Thread Dakota Jack
The rule of thumb is to use composition instead of inheritance
generally.  (Joshua Bloch, Effective Java, pp. 71 ff.)  Otherwise you
end up with fragile software.  More specifically, if the superclass
and the subclasses are in the same package and under your control,
that is more likely to be where inheritance might be useful.  In this
instance, putting these far less than generic requirements into
inheritance rather than composition is not good coding.  The problem
is that, unlike method invocation in composition, inhertitance breaks
incapsulation in classes.  This is a serious problem that should be
seen as a problem.

Consequently, I would highly recommend that you follow sound
architectural principles and build a simple class or application to
test the user which is then used in something like a two liner, e.g.
ActionForward forward = new UserCheck().checkUser(request);

ifIforward != null) {
  retun forward;
}



On 5/17/05, Joe Germuska <[EMAIL PROTECTED]> wrote:
>  From my first take on your description of the problem, I don't think
> that subclassing ActionForward is the area of Struts where you would
> enforce this.
> 
> For a new app, the simplest solution is an abstract subclass of
> Action which all of your classes extend; your subclass implements
> execute, where you put your per-request logic, and then calls another
> (abstract) method like 'doExecute", which is implemented in your
> concrete classes.  The biggest problem with this solution is that you
> "blow" your one chance at Java inheritance, so if you want to use a
> variety of superclasses, you have a lot of overhead.  But it's
> conceptually pretty simple and good for many cases.
> 
> In your case, since you've already written a lot of code, you may
> want to go straight to the more sophisticated solution, which would
> involve subclassing RequestProcessor (or TilesRequestProcessor) and
> override "processPreprocess" or "processRoles".  Assuming that you
> can implement the logic you need with whatever values are passed in
> to those methods, this provides a pretty straightforward way to do
> things.
> 
> Of course, in Struts 1.3, the ComposableRequestProcessor makes this
> even easier.
> 
> Joe
> 
> 
> At 1:48 PM -0500 5/17/05, Lee Harrington wrote:
> >I want to check to see if the user is logged in before performing any
> >action, and redirect to the login page if they are not.
> >
> >For example...they have a page open and their session times outand
> >then they click a button.  Right now an error occurs because they are
> >no longer logged in.
> >
> >I wrote a bit of code that if I put it in the beggining of an action
> >class...does just that.  But I don't want to have to put this in the
> >front of each of my actions (particularly since I've already written a
> >good portion of the app).
> >
> >Do I solve this by subclassing the action forward -- or in some other way?
> >
> >Lee
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --
> Joe Germuska
> [EMAIL PROTECTED]
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction"  -The Ex
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Subclassing ActionForward

2005-05-18 Thread Aladin Alaily
> I do not recommend using a filter.  You are much better off using what
> you've already invested your time in (Struts).

I disagree.  I think that a filter is best suited for what you are trying
to accomplish.  Whenever a request is submitted to your application, you
should verify that the user is valid before anything else takes place.  As
such, a filter meets that requirement (among other things).

In addition, implementing a filter doesn't negate any work done in struts.
 On the contrary, in my opinion, it enhances application.

> b) throw an exception that you've globally configured
>Struts to handle (declarative exception handling)

Another option is to throw a "session expired" specific exception (from
the filter) and manage it in your container.

Of course (as mentioned in another post) you can also use
response.sendRedirect("/path/to/your/action/")

Hope this helps.
Aladin


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Subclassing ActionForward

2005-05-18 Thread Lee Harrington
I'm all for doing things "the struts way".  

What I don't see in your example is WHERE to either throw the
exception or call the global forward.  I'm trying to avoid putting
this in all my actions (btw, I use dispatch actions).

I did have the foresight to subclass the dispatchAction class:

public class BaseDispatchAction extends DispatchAction {

/**
 * 
 */
public BaseDispatchAction() {
super();

}

public static void main(String[] args) {
}
}

I just don't see where I have access to my "struts goodies" like
request, mapping etc.

Sorry to be so dull.

Lee

On 5/18/05, James Mitchell <[EMAIL PROTECTED]> wrote:
> I do not recommend using a filter.  You are much better off using what
> you've already invested your time in (Struts).
> 
> By using a base action as a single point of entry into your Actions, you can
> do this check in one place, and reuse any resources already handed to you in
> your base action.
> 
> You could:
> a) forward to some global forward
> 
> For example:
> 
> 
>   
> ...(removed for brevity)...
> 
> 
> b) throw an exception that you've globally configured
>Struts to handle (declarative exception handling)
> 
> With b you now have a declarative way to handle an expired
> sessions and you have full access to your resource bundle.
> 
> With either approach, you don't have to worry about whether your app is the
> root application (http://www.myapp.com/), or nested either by configuration
> or using Modules (http://www.myapp.com/go/here/for/my/app/), all cases are
> handled.
> 
> With a filter, you would basically have to hard code where your app goes.
> For example:
>  - /foo.jsp
>  (single jsp to display some friendly error message)
> 
>  - /NonStruts/SessionExpiredCustomServlet
>  (custom servlet for dealing with sessions)
> 
>  - /SessionExpired.do
>  (forward to Struts anyway.bad idea)
> 
> Sure, you could get foo.jsp (from above) as a context-param, but I like to
> keep my work in one place, the struts-config.xml file.
> 
> --
> James Mitchell
> Software Engineer / Open Source Evangelist
> Consulting / Mentoring / Freelance
> EdgeTech, Inc.
> http://www.edgetechservices.net/
> 678.910.8017
> AIM:   jmitchtx
> Yahoo: jmitchtx
> MSN:   [EMAIL PROTECTED]
> 
> 
> - Original Message -
> From: "Lee Harrington" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" 
> Sent: Wednesday, May 18, 2005 12:07 PM
> Subject: Re: Subclassing ActionForward
> 
> Okhave a filter...it runs (use logging to determine this).
> 
> I'm stuck on how to forward to the login page.
> 
> Here's my filter code:
> 
> public void doFilter(ServletRequest request,
> ServletResponse response,
> FilterChain chain)
> throws IOException, ServletException {
> 
> try {
> chain.doFilter(request, response);
> //
> // Ensure there is a user in the session
> //
> UserDTO user = (UserDTO) request.getSession().getAttribute("user");
> if (user==null) {
> // User is not logged in, redirect to login page
> // How do I do that?
> }
> 
> } finally {
> }
> }
> 
> TIA,
> 
> Lee
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Subclassing ActionForward

2005-05-18 Thread James Mitchell
I do not recommend using a filter.  You are much better off using what 
you've already invested your time in (Struts).

By using a base action as a single point of entry into your Actions, you can 
do this check in one place, and reuse any resources already handed to you in 
your base action.

You could:
a) forward to some global forward
For example:

 
...(removed for brevity)...

b) throw an exception that you've globally configured
  Struts to handle (declarative exception handling)
With b you now have a declarative way to handle an expired
sessions and you have full access to your resource bundle.
With either approach, you don't have to worry about whether your app is the 
root application (http://www.myapp.com/), or nested either by configuration 
or using Modules (http://www.myapp.com/go/here/for/my/app/), all cases are 
handled.


With a filter, you would basically have to hard code where your app goes.
For example:
- /foo.jsp
(single jsp to display some friendly error message)
- /NonStruts/SessionExpiredCustomServlet
(custom servlet for dealing with sessions)
- /SessionExpired.do
(forward to Struts anyway.bad idea)
Sure, you could get foo.jsp (from above) as a context-param, but I like to 
keep my work in one place, the struts-config.xml file.

--
James Mitchell
Software Engineer / Open Source Evangelist
Consulting / Mentoring / Freelance
EdgeTech, Inc.
http://www.edgetechservices.net/
678.910.8017
AIM:   jmitchtx
Yahoo: jmitchtx
MSN:   [EMAIL PROTECTED]

- Original Message - 
From: "Lee Harrington" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Wednesday, May 18, 2005 12:07 PM
Subject: Re: Subclassing ActionForward

Okhave a filter...it runs (use logging to determine this).
I'm stuck on how to forward to the login page.
Here's my filter code:
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
try {
chain.doFilter(request, response);
//
// Ensure there is a user in the session
//
UserDTO user = (UserDTO) request.getSession().getAttribute("user");
if (user==null) {
// User is not logged in, redirect to login page
// How do I do that?
}
} finally {
}
}
TIA,
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-18 Thread Dave Newton
Lee Harrington wrote:
I'm stuck on how to forward to the login page.
		UserDTO user = (UserDTO) request.getSession().getAttribute("user");
		if (user==null) {
			// User is not logged in, redirect to login page
			// How do I do that?
 

response.sendRedirect("/path/to/loginAction")?
Dave

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-18 Thread Frank W. Zammetti
Pretty much the same way you do any other place...

((HttpServletResponse)response).sendRedirect("-the_url-");

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, May 18, 2005 12:07 pm, Lee Harrington said:
> Okhave a filter...it runs (use logging to determine this).
>
> I'm stuck on how to forward to the login page.
>
> Here's my filter code:
>
> public void doFilter(ServletRequest request,
>ServletResponse response,
>FilterChain chain)
>   throws IOException, ServletException {
>
>   try {
>   chain.doFilter(request, response);
>   //
>   // Ensure there is a user in the session
>   //
>   UserDTO user = (UserDTO) 
> request.getSession().getAttribute("user");
>   if (user==null) {
>   // User is not logged in, redirect to login page
>   // How do I do that?
>   }
>
>   } finally {
>   }
> }
>
> TIA,
>
> Lee
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Subclassing ActionForward

2005-05-18 Thread Lee Harrington
Okhave a filter...it runs (use logging to determine this).

I'm stuck on how to forward to the login page.

Here's my filter code:

public void doFilter(ServletRequest request,
 ServletResponse response,
 FilterChain chain)
throws IOException, ServletException {

try {
chain.doFilter(request, response);
//
// Ensure there is a user in the session
//
UserDTO user = (UserDTO) 
request.getSession().getAttribute("user");
if (user==null) {
// User is not logged in, redirect to login page
// How do I do that?
}

} finally {
}
}

TIA,

Lee

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Subclassing ActionForward

2005-05-17 Thread Robert Taylor
Look into using Filters. They are great for this kind of stuff.
/rober
Lee Harrington wrote:
I want to check to see if the user is logged in before performing any
action, and redirect to the login page if they are not.
For example...they have a page open and their session times outand
then they click a button.  Right now an error occurs because they are
no longer logged in.
I wrote a bit of code that if I put it in the beggining of an action
class...does just that.  But I don't want to have to put this in the
front of each of my actions (particularly since I've already written a
good portion of the app).
Do I solve this by subclassing the action forward -- or in some other way?
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-17 Thread Yan Hu
Hello:
I would suggest that you use servlet filters. 


--- Lee Harrington <[EMAIL PROTECTED]> wrote:
> I want to check to see if the user is logged in before performing any
> action, and redirect to the login page if they are not.
> 
> For example...they have a page open and their session times outand
> then they click a button.  Right now an error occurs because they are
> no longer logged in.
> 
> I wrote a bit of code that if I put it in the beggining of an action
> class...does just that.  But I don't want to have to put this in the
> front of each of my actions (particularly since I've already written a
> good portion of the app).
> 
> Do I solve this by subclassing the action forward -- or in some other way?
> 
> Lee
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Subclassing ActionForward

2005-05-17 Thread Josh
Lee Harrington wrote:
I want to check to see if the user is logged in before performing any
action, and redirect to the login page if they are not.
For example...they have a page open and their session times outand
then they click a button.  Right now an error occurs because they are
no longer logged in.
I wrote a bit of code that if I put it in the beggining of an action
class...does just that.  But I don't want to have to put this in the
front of each of my actions (particularly since I've already written a
good portion of the app).
Do I solve this by subclassing the action forward -- or in some other way?
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

Lee,
   Have you considered implementing a simple servlet filter to 
accomplish this? Alternatively, you could extend the RequestProcessor 
and provide a custom implementation of the processRoles method. However, 
that seems a bit heavy handed for something a simple as checking if a 
user is logged in.

Josh
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-17 Thread Joe Germuska
From my first take on your description of the problem, I don't think 
that subclassing ActionForward is the area of Struts where you would 
enforce this.

For a new app, the simplest solution is an abstract subclass of 
Action which all of your classes extend; your subclass implements 
execute, where you put your per-request logic, and then calls another 
(abstract) method like 'doExecute", which is implemented in your 
concrete classes.  The biggest problem with this solution is that you 
"blow" your one chance at Java inheritance, so if you want to use a 
variety of superclasses, you have a lot of overhead.  But it's 
conceptually pretty simple and good for many cases.

In your case, since you've already written a lot of code, you may 
want to go straight to the more sophisticated solution, which would 
involve subclassing RequestProcessor (or TilesRequestProcessor) and 
override "processPreprocess" or "processRoles".  Assuming that you 
can implement the logic you need with whatever values are passed in 
to those methods, this provides a pretty straightforward way to do 
things.

Of course, in Struts 1.3, the ComposableRequestProcessor makes this 
even easier.

Joe
At 1:48 PM -0500 5/17/05, Lee Harrington wrote:
I want to check to see if the user is logged in before performing any
action, and redirect to the login page if they are not.
For example...they have a page open and their session times outand
then they click a button.  Right now an error occurs because they are
no longer logged in.
I wrote a bit of code that if I put it in the beggining of an action
class...does just that.  But I don't want to have to put this in the
front of each of my actions (particularly since I've already written a
good portion of the app).
Do I solve this by subclassing the action forward -- or in some other way?
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

--
Joe Germuska
[EMAIL PROTECTED]  
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction"  -The Ex

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-17 Thread Frank W. Zammetti
Use a filter.  Or, write an Action base class and have all your Actions 
subclass it.  The filter is the better answer.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
Lee Harrington wrote:
I want to check to see if the user is logged in before performing any
action, and redirect to the login page if they are not.
For example...they have a page open and their session times outand
then they click a button.  Right now an error occurs because they are
no longer logged in.
I wrote a bit of code that if I put it in the beggining of an action
class...does just that.  But I don't want to have to put this in the
front of each of my actions (particularly since I've already written a
good portion of the app).
Do I solve this by subclassing the action forward -- or in some other way?
Lee
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Subclassing ActionForward

2005-05-17 Thread Dave Newton
Lee Harrington wrote:
I wrote a bit of code that if I put it in the beggining of an action
class...does just that.  But I don't want to have to put this in the
front of each of my actions (particularly since I've already written a
good portion of the app).
Do I solve this by subclassing the action forward -- or in some other way?
 

You may do it that way; STFA/STFW for others. There was a recent thread 
detailing this and other options (filters, custom request processors, 
for example), some caveats of each, etc.

Dave "The 'F' is for FABULOUS, people, not F*CKING! Sheesh!" Newton
;)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]