Skip to Content
0 %
Adding a simple web page to a Java app
// Explore More Tutorials

Adding a simple web page to a Java app


Adding a simple web page to a Java app

You will learn

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.

Creating a new HTML file
Step 2: Add body

Add the following line of code in between the opening and the closing tag:

<p>Hello World!</p>
Editing the body of the HTML file
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).

Run the java app, but use the base URL, not the servlet
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.

Editing web.xml to remove welcom-file entries

Next Steps

Back to top