Reputation: 557
I have a GWT application deployed and which i am running via calling a run configuration (Run -> Run Configurations -> Web Application -> create a new configuration -> Run). Now, this process typically deploys project on following URL: http://127.0.0.1:49240/GWTSample.jsp
But now, I have integrated rest web service in my project, and which has one URI for rest call as following: /GWTSample/rest/hello.
But when I modify actual URL to this: http://127.0.0.1:49240/GWTSample/rest/hello this URL does not work.
As a long solution, I have to compile my project and deploy it on Tomcat as following URL: http://localhost:8080/GWTSample/rest/hello, which takes more than 10 minutes every time. So how can i make rest calls on my project on http://127.0.0.1:49240/GWTSample.jsp ?
Upvotes: 1
Views: 286
Reputation: 10383
If your hostpage and your REST servlet are in the same web application then the URLs are constant relative to the web application context.
Apparently, your development mode server uses root context "/"
. So your development URL paths are "/GWTSample.jsp"
and "/rest/hello"
. But your external Tomcat uses "GWTSample"
as context which leads to URL paths of "/GWTSample/GWTSample.jsp"
for the hostpage and "/GWTSample/rest/hello"
for your REST service.
To call your REST service from your GWT app you can either use relative URLs or you determine the context path at runtime on server side (see ServletContext.getContextPath()) and pass this path to your GWT application (e.g. by integrating it into the hostpage).
The context itself is a deployment detail. Of course, you can configure your Tomcat to use root context, too. But it would be better for your application to not rely on that.
Upvotes: 1