Deploying just HTML, CSS webpage to Tomcat - html

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.

There is no real need to create a war to run it from Tomcat. You can follow these steps
Create a folder in webapps folder e.g. MyApp
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
Start tomcat and point your browser to url "http://localhost:8080/MyApp". Your index.html page will pop up in the browser

Here's my setup: I am on Ubuntu 9.10.
Now, Here's what I did.
Create a folder named "tomcat6-myapp" in /usr/share.
Create a folder "myapp" under /usr/share/tomcat6-myapp.
Copy the HTML file (that I need to deploy) to /usr/share/tomcat6-myapp/myapp. It must be named index.html.
Go to /etc/tomcat6/Catalina/localhost.
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" />
This xml is called the 'Deployment Descriptor' which Tomcat reads and automatically deploys your app named "myapp".
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!

Here's my step in Ubuntu 16.04 and Tomcat 8.
Copy folder /var/lib/tomcat8/webapps/ROOT to your folder.
cp -r /var/lib/tomcat8/webapps/ROOT /var/lib/tomcat8/webapps/{yourfolder}
Add your html, css, js, to your folder.
Open "http://localhost:8080/{yourfolder}" in browser
Notes:
If you using chrome web browser and did wrong folder before, then clean web browser's cache(or change another name) otherwise (sometimes) it always 404.
The folder META-INF with context.xml is needed.

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:
Create app folder with your static files (HTML, JS, CSS, assets, etc.).
Inside the folder create META-INF folder and add empty MANIFEST.MF.
Optionally zip the app folder and change the extension to .war.
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

Index.html without XAMPP

Is it possible to automatically load index.html on a system folder without using XAMPP, IIS or similar?
It is for a school project and I can't use them, so I have to open the file putting the path (C:/...) into the address bar.
I know I could use .htaccess, but I don't know what to write and if it gets read without any web server solutions!
This can get a little tricky... but is possible without any "administrator" privileges, nor without installing anything.
Download Python 3.8.2 - Windows x86-64 embeddable zip file
Create a folder on "python" on the c:\
Extract the "Zip" file into this folder
Change the folder name from "python-3.8.2-embed-amd64" to "python_src"
Create a folder named "python_html"
The folder structure should look like:
c:\python\
c:\python\python_src\
c:\python\python_html\
Create a file named "webserver.py" in the "c:\python\python_html" folder
Place the following code into that file:
#webserver.py
import http.server
import socketserver
PORT = 80
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
Save and close the file
Create index.html file in the "python_html" folder and place the following code in that file:
<html>
<head>
<title>Web Title</title>
</head>
<body>
<h1>Python Web Server File</h1>
<p>Congratulations! The HTTP Server is working!</p>
</body>
</html>
Open the "Command Prompt" and type the following commands
cd\
cd python\python_html\
c:\python\python_src\python ./webserver.py
Open a web browser and navigate to "http://localhost/"
Once you have confirmed this works, you can build an entire website within that "python_html" folder. As long as you don't close the command prompt it will continue acting as a "Web Server".
I know I could use .htaccess
.htaccess is an Apache (Web Server) config file, so unless you have Apache installed (ie. the "A" in XAMPP) then you can't use that. (If .htaccess was available then index.html would likely load automatically anyway.)
On Apache, being able to load index.html by default when requesting a directory requires mod_dir (an Apache module). In this case, mod_dir issues an internal subrequest for the DirectoryIndex - this all requires additional processes.
I can't install extensions... I have to open the file on my school computer
If you can't install anything then you can't do this I'm afraid. You appear to be limited to direct file requests.
When using a webserver (such as Apache or IIS) then you have a differentiation between a URL and a filesystem path. The webserver maps the URL to a filesystem path. Without a webserver you don't have that abstraction.
There are lighter webservers, other than Apache and IIS, but you need to install something extra.
Just give your file(s) meaningful names (ie. not index.html) and use those instead? eg. fox-project.html

Copy website folder and contents to Apache web server

I just started setting up Apache web server to try and test a website I am building. After installing LAMP (I'm on Ubuntu 16.04, if that's important), I copied a folder of HTML and CSS code that I had to test. Here is the folder's contents:
Main folder: testsite
Subfolders: articles, images, CSS, HTML, scripts
Contents:
articles -> .docx files
images -> .png files
CSS -> .css files
HTML -> .html files
scripts -> .py files, but one .html file too
When I went to test the Apache web server, it gave a 404 not found. I'm absolutely clueless as to what could be the answer. I tried renaming the maincode.html file that I had to index.html and putting it in the testsite folder, but it didn't change anything. Is there anything I need to do to fix this?
Here's a screenshot of the 404 Not Found page, with the Developer Console open (in Chrome)
I'm not sure what other information I need to provide, but I'll gladly give any info you need.
Make sure your testsite's conf file has the DocumentRoot property set to the path to your testsite folder. The conf file is probably /etc/apache2/sites-enabled/000-default.conf.

Website doesn't display after uploading the Yeoman created site

I am using Yeoman to create a static website, which created a file structure like:
-app
index.html
-css
style.css
-js
script.js
Gruntfile.js
README.md
bower.json
package.json
I used filezilla to send this to my server (using bluehost) but nothing seems to be displaying? when I try to hit the website. (ex. whatever.com)
Is it because my 'index.html' lives inside the app directory? Should I only host my app diretory so 'index.html' is in the root directory?
I think you are on the right track with location of index.html but not quite. Your file structure should look like:
[document root]
index.html
- css (a directory of the root)
style.css
- js (also a directory of the root same as css)
script.js
Gruntfile.js
README.md
bower.json
package.json
Note in the above structure, there is no -app folder. You can test the above by using your web browser and pointing to http://yoursite.domain/app and see if that displays.
If that does not solve the issue, then you may be uploading to somewhere outside of the document root for your web server in which case you should find out where that is. Best place to ask about that would be on either https://serverfault.com/ or on https://superuser.com/. Good luck.

How to create a website with xampp?

I created this little html file test.html:
<p>It works!</p>
and try to host it with apache. I downloaded and installed XAMPP and started apache. But where to put test.html so i can access it in the browser?
I search now for 30 minutes but can't find anything to start with.
xampp/htdocs folder, this is where index.html takes place.
You can access it via your browser like this: http://localhost/index.html
In order to add/view new files/projects, just add them to htdocs directory and access them via localhost/filename address.
Hope it works :)
In XAMPP root directory you can find 'htdocs' folder. You could create here a new folder for each web that you want to create and put inside your files. You can access in your browswer like:
http://localhost/test.html
http://localhost/NewFolder/test.html

How to Deploy html project using gradle in libgdx

I have successfully run my html project using following command
gradlew html:superDev
And after that I run "gradlew html:dist" command .
This compiled my app to Javascript and place the resulting Javascript, HTML and asset files in the html/build/dist/ folder.
Now my question is how to use this "dist" folder to run my project on server.
I tried to upload this "dist" folder on my server and then runs it's index.html file but only superDev Refresh button appears.
Please tell me what are the steps to follow after creating the dist folder ?
Which files and folder should I upload on server ?
Hi I solved it by taking following steps:-
In eclipse I right click on html project and compile it using GWT compile.
2 then run the html project as web application.
3 After successfully launching of the game I copy all the folders excepts WebInf from the war folder and place them in a new folder then upload it on server.
That's it.
But through Gradle I did not get any success.