Bryan, an example.
protected boolean processPreprocess(HttpServletRequest iRequest,
HttpServletResponse iResponse)
throws IOException, ServletException {
// check to see if a session has already been created for this user
// don't create a new session yet.
String path = processPath(iRequest);
if (!path.equalsIgnoreCase(LOGON_PATH)
&& !path.equalsIgnoreCase(LOGOFF_PATH)) {
if (!SessionContextUtil.isAuthenticated(iRequest))
{
String page = iRequest.getServletPath();
String query = iRequest.getQueryString();
if (query != null)
page = page + "?" + query;
// process the unauthenticated request
unauthenticatedUser(iResponse, iRequest, page);
return false;
}
}
return true;
}
/**
* Handle an unauthenticated request from user.
*
* @param iRequest The servlet request we are processing
* @param iResponse The servlet response we are creating
* @param iRequstedPage
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
private void unauthenticatedUser(
HttpServletResponse iResponse,
HttpServletRequest iRequest,
String iRequestedPage)
throws IOException, ServletException {
// redirect to the login servlet (passing parameter)
ActionForward logonForward = findForward(FORWARD_LOGON);
ActionForward forward = new ActionForward(logonForward.getPath(), true);
forward.setPath(forward.getPath() + "?page=" + iRequestedPage);
processActionForward(forward, iRequest, iResponse);
}
-----Original Message-----
From: Bryan Ross [mailto:[EMAIL PROTECTED]]
Sent: den 18 september 2001 05:56
To: [EMAIL PROTECTED]
Subject: processPreprocess
Hi there,
I'm trying to implement some common authentication behaviour. To do
this, I've implemented my own ActionServlet and overrided the
processPreprocess method. In this method, I want to check to see if the
user is authenticated. If they are, the processing should continue as
normal. If the user is not authenticated, I want to redirect them the
logon page.
How is this accomplihsed within the processPreprocess method? How do I
change the page that is to be displayed?
Regards,
Bryan