Message Boards

How can I redirect to any global URL from my portlet or through liferay?

Maulin Patel, modified 3 Years ago.

How can I redirect to any global URL from my portlet or through liferay?

New Member Posts: 9 Join Date: 6/16/20 Recent Posts

Hi Team,
I want to redirect to any gloab like URL like 'www.google.com'

I have tried the following code to redirect to the 'www.google.com' but it is not redirecting.

@RenderMapping
    public ModelAndView proxy(RenderRequest request, RenderResponse response)
            throws PortalException, SystemException {
        ModelAndView mv = new ModelAndView();
        try {
            logger.debug("Redirecting to proxy page");
            
            HttpServletResponse res = PortalUtil.getHttpServletResponse(response);
            res.sendRedirect("http://13.234.123.64:8080/cv/images/20201211-131135-2796/C0002007193A02.pdf");

        } catch (Exception e) {
            logger.error("proxyCVTempURL Error : {}", e);
        }
        return mv;
    }

 

Can you please help me out to redirect to any URL.

Matthew K., modified 3 Years ago.

RE: How can I redirect to any global URL from my portlet or through liferay

Junior Member Posts: 74 Join Date: 8/31/15 Recent Posts

I guess it is not possible to do a redirect in the render lifecycle of a portlet. You have to do it in the action lifecycle.

As an alternative you can just put a little javascript code into your view.jsp and do your redirect there.

thumbnail
Vilmos Papp, modified 3 Years ago.

RE: How can I redirect to any global URL from my portlet or through liferay

Liferay Master Posts: 529 Join Date: 10/21/10 Recent Posts

What is your use-case you want to achieve? Probably we can recommend alternative solution, but as Matthew wrote, basically you can do redirect in the action. Probably resource lifecycle can be also used, but again, please let us know about what is your use-case.