In one of the previous tutorial, we have learned about how to setup environment for Java web application development and two common problems related to it. In this tutorial we will learn how to start developing web application using eclipse IDE. There are simple steps to follow. First, we will create a dynamic web application project. Then we will create an HTML file in the created project and Configure it with our web application and the final step is to run the project on the Server.
- Create a dynamic web application project
1 – Right-click on the server in the project explorer tab (the server will be there if you have successfully completed our previous tutorial).
2 – click on New.
3 – click on Other.
4 – In the opened window as the search for “Web” and expand it.
5 – From the Expanded list, select Dynamic Web Project.
6 – Now click Next.
7 – Type the Project Name.
8 – Click Next.
9 – On clicking next a new window will be opened just click Next.
10 – Another window will be opened here just click finish and your project will be created.
- Create an HTML file
11 – Expand your project in the Navigator tab or Project Explorer tab now search for Web Content Right click on the Web Content.
12 – Click on New.
13 – Click on Other.
14 – Again search for “Web” in the opened window and expand it.
15 – In the expanded list you will see the “HTML File” List item, Select it.
16 – Click Next.
17 – Step 16 sill open the new window, this window is for selecting the directory to create an html file in it, here select “Web content”.
18 – In “File name” type index.html.
19 – Click Finish.
20 – You have successfully created the HTML File in the “Web Content” Folder as shown in figure.
Change HTML according to your needs.
- Configure HTML with your web application
21 – In the Navigator tab or Project Explorer tab to expand “Web Content“ and then expand “WEB-INF” there will be a web .xml file in it
22 –Open this “web.xml” file
23 – As index.html is already configured, in the opened file you will see in the “welcome-file-list” tag remove other configurations as they are not needed for now shown in figure.
- Run the project on the Server
24 – Right click on the project in the Navigator tab or Project Explorer tab.
25 – Click “Run As”.
26 – Now click “Run on server”.
27 – Select the server from “Run on server Window”, in our case it will be Tomcat as we have installed in the previous tutorial.
28 –Click finish.
29 –It will automatically open the web application tab in which the output of your index.html file will be displayed by the server.
30 –Select the link as shown in figure right click on the selection.
31 –And click “Delete” and press enter.
32 –previous step will open the server main page it means your server is now up and running, now we have successfully created and deployed our first web application project on the server.
In the next tutorial we will learn what a “Servlet” is and how to create a simple “Servlet” in our web application project.