Laliwala IT Services

Laliwala IT Services
Website Development

Monday, February 21, 2011

How to obtain the real current url?

How to obtain the real current url ?



Diego Figueroa :  Hi all,







I have a portlet and I am trying to get the current url with:





String currentURL = PortalUtil.getCurrentURL(request);





My current url is something like:





http://mysite.com/user/diego/3/....





however using the getCurrentURL() method above I get something like:





/c/portal/layout?p_l_id=3071616





instead of:





/user/diego/3





Is there another method that returns this more friendly URL?





Thanks all!





Diego.



Mazhar Anwar : I think you can try themeDisplay.getURLCurrent() method. Please check the signature in ThemeDisplay.java of portal source.





Regards,



Sandeep Nair : Hi,





Try doing this





themeDisplay.getLayout().getFriendlyURL();





Regards,





Sandeep



KK rajput : Hi ,





are you using ext environment use this

PortletURL url = PortletURLUtil.getCurrent(PortletRequest preq, MimeResponse mimeResponse or RenderResponse renderResponse)





Thanks


KamalKant



Diego Figueroa : Thank you all for your input.





I found the solution I wanted thanks to your information:





PortalUtil.getLayoutURL(themeDisplay.getLayout(),themeDisplay);





This gives me the complete URL that I wanted









28 comments:

  1. try this ..

    PortalUtil.getCurrentURL(PortalUtil.getHttpServletRequest(portletRequest))

    Lifery 6.1

    ReplyDelete
  2. what is portletRequest;

    ReplyDelete
  3. 14CEDMichelleB793FApril 14, 2024 at 1:58 AM

    59E75
    ----
    ----
    ----
    ----
    ----
    matadorbet
    ----
    ----
    ----

    ReplyDelete