Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

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

    Thanks a lot. Problem solved.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.