RE: Context path after dispath view.jsp not correct in liferay DXP

David Chung, modified 5 Years ago. New Member Posts: 3 Join Date: 2/7/20 Recent Posts
I am using spring MVC with gwt which need dispath to view.jsp and then it push frontend to redirect and it will download some file from server to load the page, but the file context path not correct after deploy to liferay DXP.
The find path should be like that
https://<hostname>/<context path>/<source folder>/xxxxxxxxxxxx.cache.js
but after deploy to liferay DXP change to like this
https://<hostname>/xxxxxxxxxxxx.cache.js

I know that after liferay DXP the file path should change to below and I try to get the file successful by using this path but how can I change the context path under liferay DXP
https://<hostname>/o/<context path>/<source folder>/xxxxxxxxxxxx.cache.js

GenericPortlet.java
    @Override
    protected void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException {
            
        request.setAttribute("DEFAULT_RENDER_URL", response.createRenderURL().toString());
        
        response.setContentType(request.getResponseContentType());
        String url = "/WEB-INF/jsp/view.jsp";
        getPortletContext().getRequestDispatcher(url).include(request, response);
    }
 
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
You can change the /o to something else, but you cannot get rid of the /o.

Normally to accommodate something like this I like to use a rewrite rule in apache or nginx to take the incoming URL that you want to do and send it to the URL that Liferay expects. It's the best way to keep what you need yet live with what Liferay requires.