Skip to Content
author's profile photo
Former Member

Portal URL retrieval

I would like to retrieve the portal url only in my java code. for example if the portal url is http://www.abc.com/sapportal/... i would like to retrieve only this bit (http://www.abc.com/sapportal). I have tried using the URL generator but it retrieves only the latter part i.e /irj/servlet etc...

Any help will be appreciated. Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    May 17, 2004 at 11:48 PM

    Hi,

    You can use the IPortalComponentURI APIs to find the URL for your java component. For example:

    -


    IPortalComponentURI componentURI = componentRequest.createPortalComponentURI();

    componentURI.setContextName("com.sap.km.cm.service");

    String searchComponentURI = componentURI.toString();

    -


    this would set searchComponentURI = http://myportal.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.service

    I know that it is not what you were asking for specifically, however it is possible to parse the string to get what you want without too much hardcoding.

    Cheers,

    Vic

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    May 18, 2004 at 06:17 AM

    Hi,

    you have to use the HttpServletRequest which is in package javax.servlet.http (servlet.jar).

    You retrieve this by calling IPortalComponentRequest.getServletRequest(); You only see this method after you added the servlet.jar to your classpath.

    There you find all methods you are looking for to retrieve the url path.

    Regards,

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    May 18, 2004 at 08:41 AM

    Thanks a lot. Problem solved.

    Add comment
    10|10000 characters needed characters exceeded