David G. Friedman wrote:
Luke,
Can you include some of the code for your TilesRequestProcessor subclass as
well as how you initialize it in your struts-config.xml (or modules) ?
Regards,
David
-----Original Message-----
Sure!
The CustomRequestProcessor is taken from a book by Mike Robinson:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
package com.mycompany.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
//import org.apache.struts.action.RequestProcessor;
import org.apache.struts.tiles.TilesRequestProcessor;
/**
* @author Mike Robinson
*
*/
public class CustomRequestProcessor extends TilesRequestProcessor
{
/**
* Handles validating of each user request, insuring that
* the user has logged in properly. If not, they get re-directed
* to the login page.
*/
protected boolean processPreprocess(HttpServletRequest request,
HttpServletResponse response)
{
boolean continueProcessing = true;
// Test if the request is a login request
try
{
HttpSession session = null;
// make sure session has not timed out
if(request.isRequestedSessionIdValid())
session = request.getSession();
else
response.sendRedirect("index.jsp?invalid=yes");
// get the current request path
String path = processPath(request, response);
// if user is not trying to logon or join, make sure user has been
authenticated
if ((!path.equals((String) "/index"))&&( !path.equals((String)
"/join")))
{
// get the user bean
UserDTO user = (UserDTO)
session.getAttribute("user");
// insure user has logged on
if (user == null) // else make them logon
first
{
try
{
response.sendRedirect("index.jsp?invalid=yes");
}
catch(Exception ioe)
{
log.error("problem redirecting in processPreprocess - " +
ioe.getMessage());
}
continueProcessing = false;
}
}
}
catch(Exception ioe)
{
log.error("problem processing path - " +
ioe.getMessage());
continueProcessing = false;
}
return continueProcessing;
}
}
^^^^^^^^^^^^^^^^^^^^^^^^ì
<!-- ========== Controller Definition ============================== -->
<controller processorClass="com.mycompany.struts.CustomRequestProcessor"
/>
--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Sponsor:
Niente paura, da oggi puoi recuperare i dati persi dal PC, semplice come
cliccare qui
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid361&d=5-6
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]