Deploying just HTML, CSS webpage to Tomcat

Viewed 185644

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.

6 Answers

If you want to create a .war file you can deploy to a Tomcat instance using the Manager app, create a folder, put all your files in that folder (including an index.html file) move your terminal window into that folder, and execute the following command:

zip -r <AppName>.war *

I've tested it with Tomcat 8 on the Mac, but it should work anywhere

(Answers are pretty old, so here's what worked for me on Ubuntu 20.04 Tomcat9) As root

  cd /var/lib/tomcat9/webapps
  mkdir -p myapp
  cd myapp
  cat >>index.html
  <html><body>MY SIMPLE PAGE </body></html>
  control-D # Press CONTROL+D to exit 'cat', create the file 'index.html'
  systemctl restart tomcat9

In browser, use URL: http://127.0.0.1/myapp
(Of course, you can make page fancier, add CSS, etc., etc.)

I struggled a bit with older version of Apache Tomcat (7.0.68) running on Windows Server 2012, but this worked for me after a little bit of experimenting:

  1. Create app folder with your static files (HTML, JS, CSS, assets, etc.).
  2. Inside the folder create META-INF folder and add empty MANIFEST.MF.
  3. Optionally zip the app folder and change the extension to .war.
  4. Upload your app to Tomcat's webapps folder, either as a .war or just folder with your files.

Turned out, that META-INF with empty MANIFEST.MF file is enough for Tomcat to serve the app. No need to add WEB-INF or anything else (at least for my version of Tomcat).

Folder structure:

MyApp (folder)
|--index.html
|--app.js
|--app.css
|--assets (folder)
   |--logo.png
   |--...
|--META-INF (folder)
   |--MANIFEST.MF (empty file)
Related