Sanjay Naik
Sanjay Naik

Reputation: 328

How to retrieve page URL In a API which is being invoked?

I have a Rest-API which is being invoked from multiple pages.On successful execution of API it gets directed to another page.I want to redirect my API success call to another page if the API is being invoked from a particular page

I created one dummy API namely /deleteMe which invokes a method in my class.I am trying to retrieve the page URL from which this API is being fired.

API Structure

        <actor-chain id="deleteMe" transaction="TX_SUPPORTS">
         <component id="getRemoveGiftItemIds" name="/atg/userprofiling/ProfileTools" method="deleteMe" method-return-var="removeGiftItemIds" invoke-method-requires-session-confirmation="false">
            <input name="url" value="https://${nucleus['/OriginatingRequest'].requestURL}"/>
         </component>
        </actor-chain>

Below is the method which the above API is invoking

 public void deleteMe(String url){
       System.out.println("----Inside deleteMe()---");
       System.out.println("-----url----"+url);
 }

How to find out the page URL from which API is being invoked?

Upvotes: 0

Views: 121

Answers (1)

radimpe
radimpe

Reputation: 3215

You will need to interrogate the request object inside the ProfileTools class. From here you should be able to extract the attributes, one of which is javax.servlet.forward.context_path which is likely to give you what you need.

Upvotes: -1

Related Questions