In this tutorial you will learn how to add a basic HTML page to a Java app.
Step 1: Create a new HTML page
Navigate to the webapp node in the Project Explorer and create a new HTML page by selecting the respective context menu entry: New > HTML File.
Choose the name index.html and click on Finish.
Step 2: Add body
Add the following line of code in between the opening and the closing
tag:
<p>Hello World!</p>
Step 3: Save and publish locally
Save your changes and publish the update project to the local server by selecting the respective context menu on the server in the Server view.
Step 4: View app
Once the publishing is done you can go back to the internal browser window and remove the /hello part of the URL and hit the Enter key. Now, you should see the same “Hello World!” message for the URL http://localhost:8080/weatherapp/ as well. The reason for this is the <welcome-file-list> in the web.xml (located in the WEB-INF directory underneath the webapp folder).
Step 5: Clean up entries
For security reasons and for the sake of housekeeping you should remove all entries except for the index.html entry from the web.xml file.