Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include HTML File in Eclipse Dynamic Web Project

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.

like image 236
ZKSteffel Avatar asked Jun 15 '11 19:06

ZKSteffel


People also ask

Where do I put HTML files in Eclipse Dynamic Web Project?

Put your pages under WEB-INF folder, in that way they cannot be accessed directly. Also look at maven directory layout http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html. Save this answer.

How do I import a dynamic Web project into Eclipse?

Step 1: Open your Eclipse IDE and go to File » Import. Step 2: Search for Existing Projects into Workspace or go to General » Existing Project into Workspace » Next. Step 3: Browse your Web Project from the root directory and click on Finish button.

Can we code HTML and css in Eclipse?

Eclipse Web Developer ToolsIncludes the HTML, CSS, and JSON Editors, and JavaScript Development Tools from the Eclipse Web Tools Platform project, aimed at supporting client-side web development and node.


2 Answers

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.

like image 51
Siddharth Avatar answered Oct 20 '22 18:10

Siddharth


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.

like image 25
ZKSteffel Avatar answered Oct 20 '22 17:10

ZKSteffel