Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 406428

Summary: ServiceManager#getServiceHandlerUrl should return relative URLs
Product: [RT] RAP Reporter: Holger Staudacher <holger.staudacher>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: hannes, jboehme, mknauer, rsternberg
Version: 2.0   
Target Milestone: 2.3 M2   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Holger Staudacher CLA 2013-04-24 09:09:13 EDT
In RAP most protocol messages containing pathes e.g. to resources are relative. This make it very easy for clients to compose the url for a request. Today we implemented a service handler for a custom widget and we needed to send the service handler url to the client.

We noticed the ServiceManager#getServiceHandlerUrl always returns an absolute path. It also seems that it ignores the "context" property of the ApplicationConfiguration service. 

So, as a result the client couldn't do anything with this url. Maybe it would be a good change to always return ENTRYPOINT?serviceHandler=ID instead of trying to work out the full path. 

I also noticed the the implementation of this method uses the context path. This may lead to problems too e.g. when he servlet container may be behind a load balancer or something similar.
Comment 1 Ralf Sternberg CLA 2013-04-24 11:28:52 EDT
(In reply to comment #0)
> We noticed the ServiceManager#getServiceHandlerUrl always returns an absolute
> path. It also seems that it ignores the "context" property of the
> ApplicationConfiguration service.

RWT does not depend on OSGi and knows nothing about the service property. However, the context path is taken into account, as the URL is based on the actual POST request. For example, if the context path is /context/, the URL returned by getServiceHandlerUrl() will be something like

  /context/servlet?servicehandler=bar&cid=cc36429c

I don't see the advantage of a relative path yet. Why would that be easier for you?

> So, as a result the client couldn't do anything with this url.

I couldn't follow. Which part of the URL is inappropriate and why? Could you provide an example as returned by getServiceHandlerUrl() and explain what you'd expect?

> I also noticed the the implementation of this method uses the context path. This
> may lead to problems too e.g. when he servlet container may be behind a load
> balancer or something similar.

Could you explain why this could be a problem?
Comment 2 Ralf Sternberg CLA 2014-02-23 05:47:38 EST
Absolute URLs are problematic in server environments that rewrite URLs.

Since servicehandler requests are handled by the RWTServlet, we should be able to use relative URLs instead. These would not require any additional rewrite rules.
Comment 3 Ralf Sternberg CLA 2014-02-26 10:38:28 EST
Fixed with https://git.eclipse.org/r/#/c/22518/

ServiceManager.getServiceHandlerUrl() now returns relative URLs in the form `?servicehandler=foo`.
Comment 4 Hannes Erven CLA 2014-06-11 12:39:48 EDT
I think this changed has caused a regression when the client does not use cookies, please see bug#437211 .