views:

36

answers:

2

I am just getting started on developing a website. All I have at the moment is a HTML page supported by a couple of CSS stylesheets.

Can I create a WAR file from the HTML and CSS pages? How do I deploy them on to a Tomcat server?

Thanks.

+1  A: 

There is no real need to create a war to run it from Tomcat. You can follow these steps

  1. Create a folder in webapps folder e.g. MyApp

  2. Put your html and css in that folder and name the html file, which you want to be the starting page for your application, index.html

  3. Start tomcat and point your browser to url "http://localhost:8080/MyApp". Your index.html page will pop up in the browser

Gaurav Saxena
I created a folder MyApp1 under /usr/share/tomcat6/webapps/ and copied the html I am working with to MyApp1, renamed it to index.html.http://localhost:8080/MyApp1 - gives 404 error.
Van de Graff
Just downloaded tomcat 6, tried to the above on my windows XP and it worked. Since you are running it on linux (I guess from 'usr/share') I cannot recreate your scenario completely but try the following things - point your browser to localhost:8080. If you see the tomcat manager page, on the bottom left corner, click on servlet examples. Check the path of the resulting page. It points to index.html in servlets folder path of which is given by the page in browser. You need to set up your application on the same lines
Gaurav Saxena
A: 

Here's my setup: I am on Ubuntu 9.10.

Now, Here's what I did.

  1. Create a folder named "tomcat6-myapp" in /usr/share.
  2. Create a folder "myapp" under /usr/share/tomcat6-myapp.
  3. Copy the HTML file (that I need to deploy) to /usr/share/tomcat6-myapp/myapp. It must be named index.html.
  4. Go to /etc/tomcat6/Catalina/localhost.
  5. Create an xml file "myapp.xml" (i guess it must have the same name as the name of the folder in step 2) inside /etc/tomcat6/Catalina/localhost with the following contents.

< Context path="/myapp"

docBase="/usr/share/tomcat6-myapp/myapp"/>

6.This xml is called the 'Deployment Descriptor' which Tomcat reads and automatically deploys your app named "myapp".

7.Now go to http://localhost:8080/myapp in your browser- the index.html gets picked up by tomcat and is shown.

I hope this helps!

Van de Graff