I'm new to
struts, I got a task in which i must redirect to other website when a user log out
This is the code which extends TilesRequestProcessor, can anyone give me some clue where in this code i should put a line to redirect user to other url? Any feedbacks will be fully appreciated
code:
public class SmukAntamRequestProcessor extends TilesRequestProcessor {
protected boolean processPreprocess(HttpServletRequest request, HttpServletResponse response) {
boolean continueProcessing = true;
if (request.getServletPath().equals("/loginInput.do")
|| request.getServletPath().equals("/login.do"))
return true;
HttpSession session = request.getSession();
//Check if userName attribute is there is session.
//If so, it means user has allready logged in
if (session != null &&
session.getAttribute(AppSmukConstants.SESS_USER_NAME) != null)
return true;
else {
try {
//If no redirect user to login Page
request.getRequestDispatcher
("/login.do").forward(request, response);
} catch (Exception ex) {
}
}
return false;
}
protected boolean processRoles(HttpServletRequest request,
HttpServletResponse response,
ActionMapping mapping)
throws IOException, ServletException {
// Is this action protected by role requirements?
String roles[] = mapping.getRoleNames();
if ((roles == null) || (roles.length < 1)) {
return (true);
}
HttpSession session = request.getSession();
if (session == null) return (false);
List rolesInSession = (List) session.getAttribute(AppSmukConstants.SESS_USER_ROLE);
// Check the current user against the list of required roles
for (int i = 0; i < roles.length; i++) {
if (rolesInSession.contains(roles[i]) ) {
if (log.isDebugEnabled()) {
log.debug(" User '" + request.getRemoteUser() +
"' has role '" + roles[i] + "', granting access");
}
return (true);
}
}
// The current user is not authorized for this action
if (log.isDebugEnabled()) {
log.debug(" User '" + request.getRemoteUser() +
"' does not have any required role, denying access");
}
response.sendError(
HttpServletResponse.SC_FORBIDDEN,
getInternal().getMessage("notAuthorized", mapping.getPath()));
return (false);
}
}