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
+ SampleHTMLSite.war
- index.html
To create the .war
file just zip your index.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's dropins
folder (usually located here: ...\wlp\usr\servers\YourServerName\dropins
) you will get something like the following update:
[AUDIT ] CWWKT0016I: Web application available (default_host):
http://localhost:9080/SampleHTMLSite/
[AUDIT ] CWWKZ0001I: Application SampleHTMLSite started in 0.317 seconds.
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:
Error 404: java.io.FileNotFoundException: SRVE0190E: File not found: /index.html
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:
+ SampleHTMLSite.war
+ SampleHTMLSite
- index.html
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
The simplest:
dropins
folder (\wlp\usr\servers\serverName\dropins
), create folder myApp.war
index.html
in the myApp.war
If your server is configured for polled monitoring you are done. Otherwise restart the server (if was started).
It will be available via http://host:port/myApp/index.html
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With