Mike Deegan wrote: [snip]
import org.apache.struts.config.ForwardConfig;^^^^^^^^^^^
{
ForwardConfig fc = mapping.getModuleConfig().findForwardConfig("unauthorized");
request.getRequestDispatcher(fc.getPath()).forward(request,response); }
Thanks, my problem with this is that processPreprocess() doesn't have an ActionMapping parameter, so I guess what I should have asked was, "How can I make an ActionMapping?" However, I'm now thinking, "I was tired earlier and should just have overridden processRoles() and not processPreprocess()"!
----- Original Message ----- From: "David Kennedy" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Sunday, March 20, 2005 7:25 AM
Subject: How to call a Struts 'forward' from a CustomRequestProcessor?
Easy one for a Sunday morning:
I'm got a simple CustomRequestProcessor which checks for the presence of a user login bean, and if not found, it should bounce the request to my logon page.
Problem: how can I say "Go to the Struts Forward /logon" from within the CustomRequestProcessor?
Bonus points: how can I stop the browser's 'Back' key letting the user cheat...
protected boolean processPreprocess(HttpServletRequest request,
HttpServletResponse response)
{
final HttpSession session = request.getSession(false);
final Logger log = Logger.getLogger(this.getClass());
final String path = request.getServletPath();
if (path.equals("/logon") || path.equals("/logon.do"))
{
return true;
}
if (session != null
&&
session.getAttribute(ApplicationAttributes.USER_KEY) != null)
{
if (log.isDebugEnabled())
{
log.debug("User bean located in session. Permitting request...");
}
return true;
}
else
{
if (log.isDebugEnabled())
{
log.debug("No user bean located in session. Refusing request and forwarding to logon...");
}
try
{
// ***************************************
// ***************************************
// ** HOW CAN I MAKE THIS CALL A STRUTS **
// ** FORWARD CALLED '/logon' INSTEAD? **
// ***************************************
// ***************************************
request.getRequestDispatcher(
"/logon/logon.jsp").forward(request, response);
}
catch(Exception e)
{
log.error("Unable to forward to /logon",e);
}
}
return false;
}
-- David Kennedy Swan Labs http://www.swanlabs.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- David Kennedy Swan Labs http://www.swanlabs.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]