Reputation: 1125
I know there has to be a simple answer to this, but Google's not helping at the moment. I've got a dynamic web project in Eclipse which is using Java/Jersey to run a web service. All my java resources are called in a URI like projectname/test/statistics
, etc. for different resources. My hangup is on a relatively simple point:
How do I include an HTML file in this project?
I'm planning to have this file as a sort of 'home page', in order to handle logins, etc. I'd like the URI to be something like projectname/
or projectname/login
, but I can't seem to find where I can define the path to reference the HTML file. Is there something I need to add to the HTML itself, or is it a setting in the Eclipse project?
Update:
Soo... I still can't run my html file through eclipse. What I have to do right now is deploy a war to Tomcat without the html, then put the html file in a completely separate folder to run it. This means that I have to type a different context root whenever I call my file.
Upvotes: 9
Views: 38565
Reputation: 396
I solved this problem by changing web.xml from:
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
to
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
And then http://servername/MyWebApp
launched index.html correctly.
Upvotes: 13
Reputation: 1125
My workaround:
Since I haven't been able to get this working directly in Eclipse, I've been placing my html page manually in the directory where my service is deployed to Tomcat. Placing it in the ROOT folder lets me hit the page at localhost:8080/login.html
, and I can deploy it to other folders, say Test, to hit it at localhost:8080/Test/login.html
, but due to my security settings (at the moment), I cannot place it in the same folder as the rest of my deployed project.
Upvotes: 2
Reputation: 19867
If you created your project in Eclipse, you probably have a WebContent folder off of the root of your project. Files placed in there will be served relative to your project's context root.
For example, if your context root is MyWebApp
, and you put the file hello.html
into the WebContent folder, you can see your file at http://servername/MyWebApp/hello.html
.
Your context root can be found/changed by going to the project properties and selecting "Web Project Settings".
Upvotes: 10