1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.jsp;
12
13 import jakarta.servlet.http.HttpServletRequest;
14 import jakarta.servlet.http.HttpServletResponse;
15 import jakarta.servlet.http.HttpSession;
16
17 import org.apache.catalina.Context;
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 import psiprobe.model.jsp.Summary;
27
28
29
30
31 @Controller
32 public class DisplayJspController extends AbstractContextHandlerController {
33
34
35 public static final String SUMMARY_ATTRIBUTE = "jsp.summary";
36
37 @RequestMapping(path = "/app/jsp.htm")
38 @Override
39 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
40 throws Exception {
41 return super.handleRequest(request, response);
42 }
43
44 @Override
45 protected ModelAndView handleContext(String contextName, Context context,
46 HttpServletRequest request, HttpServletResponse response) throws Exception {
47 boolean compile = ServletRequestUtils.getBooleanParameter(request, "compile", false);
48
49 HttpSession session = request.getSession(false);
50 Summary summary = (Summary) session.getAttribute(SUMMARY_ATTRIBUTE);
51 if (summary == null || !contextName.equals(summary.getName())) {
52 summary = new Summary();
53 summary.setName(contextName);
54 }
55 getContainerWrapper().getTomcatContainer().listContextJsps(context, summary, compile);
56
57 request.getSession(false).setAttribute(SUMMARY_ATTRIBUTE, summary);
58
59 if (compile) {
60 return new ModelAndView(new RedirectView(
61 request.getRequestURI() + "?webapp=" + (contextName.length() == 0 ? "/" : contextName)));
62 }
63 return new ModelAndView(getViewName(), "summary", summary);
64 }
65
66 @Value("showjsps")
67 @Override
68 public void setViewName(String viewName) {
69 super.setViewName(viewName);
70 }
71
72 }