Reference JSP in a controller

Follow the procedure below to reference JSP in a controller

See Also
Create and package a controller
  1. Copy your JSP somewhere within the following directory: <DATADIR>/webapps/360-mashup-ui/WEB-INF/jsp/
  2. Edit the following file: <DATADIR>/webapps/360-mashup-ui/WEB-INF/tiles-def.xml
  3. Add a line within <tiles-definitions>, for example: <definition name="mytemplate" template="/WEB-INF/jsp/path/of/the/jsp/page.jsp" />
  4. Create and package a custom controller and deploy it as a plugin, for example:

    package com.exalead.cv360.searchui.view.widgets.controller;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    
    @Controller
    public class TestController {
        @RequestMapping(value = "/test", method = { RequestMethod.GET, RequestMethod.POST })
        public String test(HttpServletRequest request, HttpServletResponse response) {
            return "mytemplate";
        }
    }

  5. Restart the search server.

    Your page should be accessible at the following URL: http://<HOSTNAME>:<PORT>/mashup-ui/test Where:

    • mashup-ui is the context path of the application deployed by jetty.
    • /test is the path specified by the @RequestMapping annotation.

    Note: The default controller renders pages as /page/pageName, for example, http://<HOSTNAME>:<PORT>/mashup-ui/page/search and is written as follows:

      @RequestMapping(value = "/page/{pageName}", method = RequestMethod.GET) 
        public String renderPage(HttpServletRequest request, HttpServletResponse response, @PathVariable
    (“pageName”) String pageName) throws Exception {
        }