This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes how to redirect to other URL ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to redirect to other URL ?" Watch "how to redirect to other URL ?" New topic

how to redirect to other URL ?

pingkan paula
Ranch Hand

Joined: Sep 03, 2004
Posts: 117
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


public class SmukAntamRequestProcessor extends TilesRequestProcessor {

protected boolean processPreprocess(HttpServletRequest request, HttpServletResponse response) {
boolean continueProcessing = true;
if (request.getServletPath().equals("/")
|| request.getServletPath().equals("/"))
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
("/").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");

getInternal().getMessage("notAuthorized", mapping.getPath()));

return (false);

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You don't need to extend the RequestProcessor just to redirect to a different site when the user logs out.

Just create a forward specifying the full URL of the link you want to forward to (including the HTTP://) and specify redirect="true". Then just find the forward and return it from the execute() method of your logout action as you would with any forward.

Consultant, Sima Solutions
subject: how to redirect to other URL ?
Similar Threads
Session out in Struts
Basic Check for user log in before executing actions.
redirect to other url from TilesRequestProcessor
problem in session tracking inside my request processor....
Session Tracking In struts