View Javadoc

1   package org.paneris.user.controller;
2   
3   import javax.servlet.http.HttpSession;
4   
5   import org.paneris.util.SessionUtil;
6   import org.webmacro.Template;
7   import org.webmacro.servlet.HandlerException;
8   import org.webmacro.servlet.PanerisPage;
9   import org.webmacro.servlet.WebContext;
10  
11  public class LogoutUser extends PanerisPage {
12  
13    private static final long serialVersionUID = 1L;
14  
15      public Template handle(WebContext context) throws HandlerException {
16          String db = (String) context.getForm("db");
17          context.put("db",db);
18          // return the appropriate template
19          String templateName = (String) context.getForm("wmtemplate");
20          if (templateName == null) templateName = "user/view/UserLogout.wm";
21          if (context.getCGI().getHTTP_REFERER() != null) 
22            context.getSession()
23               .setAttribute("LogoutUserReturnURL", 
24                             context.getCGI().getHTTP_REFERER());
25          SessionUtil.setReturnURL("LogoutUserReturnURL",context);
26          HttpSession s = context.getSession();
27          s.removeAttribute(db+"user");
28          // force the next page to check for a new style
29          s.removeAttribute(db+"stylepath");
30          try {
31              return (Template) context.getBroker().get("template",templateName);
32          } catch (Exception e) {
33              throw new HandlerException("Could not locate template: " + templateName);
34          }
35      }
36  }