1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.sessions;
12
13 import jakarta.servlet.http.HttpServletRequest;
14 import jakarta.servlet.http.HttpServletResponse;
15
16 import org.apache.catalina.Context;
17 import org.apache.catalina.Session;
18 import org.springframework.beans.factory.annotation.Value;
19 import org.springframework.stereotype.Controller;
20 import org.springframework.web.bind.ServletRequestUtils;
21 import org.springframework.web.bind.annotation.RequestMapping;
22 import org.springframework.web.servlet.ModelAndView;
23 import org.springframework.web.servlet.view.RedirectView;
24
25 import psiprobe.controllers.AbstractContextHandlerController;
26
27
28
29
30 @Controller
31 public class RemoveSessAttributeController extends AbstractContextHandlerController {
32
33 @RequestMapping(path = "/app/rmsattr.htm")
34 @Override
35 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
36 throws Exception {
37 return super.handleRequest(request, response);
38 }
39
40 @Override
41 protected ModelAndView handleContext(String contextName, Context context,
42 HttpServletRequest request, HttpServletResponse response) throws Exception {
43
44 String sid = ServletRequestUtils.getStringParameter(request, "sid");
45 String attrName = ServletRequestUtils.getStringParameter(request, "attr");
46 Session session = context.getManager().findSession(sid);
47 if (session != null) {
48 session.getSession().removeAttribute(attrName);
49 }
50
51 return new ModelAndView(new RedirectView(
52 request.getContextPath() + getViewName() + "?" + request.getQueryString()));
53 }
54
55 @Value("/attributes.htm")
56 @Override
57 public void setViewName(String viewName) {
58 super.setViewName(viewName);
59 }
60
61 }