How do I display an HTML file using Websphere Liberty?
Asked Answered
F

2

5

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?

Flighty answered 4/12, 2014 at 22:17 Comment(0)
P
9

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

Plast answered 4/12, 2014 at 22:19 Comment(1)
To make things easier, you don't actually have to create the archive (zip/war), and instead you can just create the folder that's named with the ".war" suffix like "SampleHTMLSite.war"Yahairayahata
S
6

The simplest:

  • In dropins folder (\wlp\usr\servers\serverName\dropins), create folder myApp.war
  • put your 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.

Saree answered 4/12, 2014 at 23:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.