View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.controllers.jsp;
12  
13  import jakarta.servlet.http.HttpServletRequest;
14  import jakarta.servlet.http.HttpServletResponse;
15  
16  import org.apache.catalina.Context;
17  import org.springframework.beans.factory.annotation.Value;
18  import org.springframework.stereotype.Controller;
19  import org.springframework.web.bind.annotation.RequestMapping;
20  import org.springframework.web.servlet.ModelAndView;
21  import org.springframework.web.servlet.view.RedirectView;
22  
23  import psiprobe.controllers.AbstractContextHandlerController;
24  
25  /**
26   * The Class DiscardCompiledJspController.
27   */
28  @Controller
29  public class DiscardCompiledJspController extends AbstractContextHandlerController {
30  
31    @RequestMapping(path = "/adm/discard.htm")
32    @Override
33    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
34        throws Exception {
35      return super.handleRequest(request, response);
36    }
37  
38    @Override
39    protected ModelAndView handleContext(String contextName, Context context,
40        HttpServletRequest request, HttpServletResponse response) throws Exception {
41  
42      getContainerWrapper().getTomcatContainer().discardWorkDir(context);
43      return new ModelAndView(new RedirectView(
44          request.getContextPath() + getViewName() + "?" + request.getQueryString()));
45    }
46  
47    @Value("/app/jsp.htm")
48    @Override
49    public void setViewName(String viewName) {
50      super.setViewName(viewName);
51    }
52  
53  }