how to get the web app context root path in a rest service
How can I retrieve the web app context path in a jfs rest service?
I contribute a rest service using the extension point:
<restService>
</restService>
The service url looks like: "https://localhost:9444/my_web_context_name/my_service_base"
In the service implementation class (com.example.MyService), I need to retrieve the web app context root path ("https://localhost:9444/my_web_context_name"). Yes, I can do this by parsing the http request uri. My question is: is there an API to retrieve the web app context path directly?
I contribute a rest service using the extension point:
<restService>
</restService>
The service url looks like: "https://localhost:9444/my_web_context_name/my_service_base"
In the service implementation class (com.example.MyService), I need to retrieve the web app context root path ("https://localhost:9444/my_web_context_name"). Yes, I can do this by parsing the http request uri. My question is: is there an API to retrieve the web app context path directly?
One answer
You can use the com.ibm.team.jfs.app.RequestParam class to retrieve lots of parameters having to do with requests and the application configuration. In particular, the getContextPath method will return the context path. You would do something like this in a service method:
String contextPath = RequestParams.getContextPath(request.getParams());
How can I retrieve the web app context path in a jfs rest service?
I contribute a rest service using the extension point:
<restService>
</restService>
The service url looks like: "https://localhost:9444/my_web_context_name/my_service_base"
In the service implementation class (com.example.MyService), I need to retrieve the web app context root path ("https://localhost:9444/my_web_context_name"). Yes, I can do this by parsing the http request uri. My question is: is there an API to retrieve the web app context path directly?