I have static HTML pages. Using the Apache server (through XAMPP) I used to put my HTML files in the htdocs
folder and they would be accessible through the localhost URL.
I'm not sure how to do this with Websphere Liberty server. let's say I have the following HellWorld HTML example in index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HellWorld</title>
</head>
<body>
<p>HellWorld</p>
</body>
</html>
How can I get this HTML page to show in the browser through Liberty?
The minimum folder structure needed is the following
To create the
.war
file just zip yourindex.html
file and then change the extention of the zipped folder from.zip
to.war
If you are running Liberty sever in foreground through
server run
command, as soon as you put this website in Liberty'sdropins
folder (usually located here:...\wlp\usr\servers\YourServerName\dropins
) you will get something like the following update:If you go to
http://localhost:9080/SampleHTMLSite/index.html
you should be able to see your HelloWorld HTML page.If you get the following error:
Open your SampleHTMLSite.war with any unzipping program (example: 7-Zip) and be sure that the
index.html
is showing directly inside the.war
file and not inside another folder. There is a chance that you have the following structure:This would mean to access the
index.html
you need the following URL:http://localhost:9080/SampleHTMLSite/SampleHTMLSite/index.html
In bigger project and where you need to use Java apps your folder structure might need to include other folders and files. If you are intrested to know more about this, check the following article:
Handling Static Content in WebSphere Application Server