Perform our logged-in user check by looking for the existence of
a session scope bean under the specified name. If this bean is not
present, control is forwarded to the specified logon page.
// Is there a valid user logged on?
boolean valid = false;
HttpSession session = pageContext.getSession();
if ((session != null) && (session.getAttribute(name) != null)) {
valid = true;
}
// Forward control based on the results
if (valid) {
return (EVAL_PAGE);
} else {
ModuleConfig config =
(ModuleConfig) pageContext.getServletContext().getAttribute(
org.apache.struts.Globals.MODULE_KEY);
try {
pageContext.forward(config.getPrefix() + page);
} catch (ServletException e) {
throw new JspException(e.toString());
} catch (IOException e) {
throw new JspException(e.toString());
}
return (SKIP_PAGE);
}