Configure Web Project
I will explain how to configure a Java 8 web project with Eclipse and Maven and deploy it on an Apache Tomcat server. As a test we will create a “Hello World” home page in jsp.
Once the necessary is installed (if you have any doubts, see the article Create Web Project with Eclipse and Maven), and with Eclipse running, display the context menu of the project using the right mouse button and select Properties.
Activate the options in the Java Compiler section in the left area. Uncheck the Use Compliance from Execution environment … box and choose 1.8 from the drop-down list.
Then activate the Project Facets section, choose Java version 1.8 again and uncheck the Dynamic Web Module box. Press Apply.
Again check the Dynamic Web Module box. Notice that an option appears in the lower part of the window (Futher configuration available). Click on it.
Enter the path src/main/webapp in Conent directory an press Ok.
This will create the deployment file web.xml.
Press Apply and Close. Select Yes. As you can see, the compilation errors have disappeared.
Create test jsp page
As a last step, we will create a test jsp page.
Go to the directory
Go to the directory
Go to the directory src/main/webapp and show its context menu. Select New -> Other -> Web (JSP File). Press Next and give it a name index.jsp. Press Finish.
Write a test text, for example:
When creating the page, the following error is generated:
The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
Open the pom.xml file and insert the following lines before closing the element </Project>:
Add Apache Tomcat Server to Eclipse
From Eclipse, activate the Servers tab in the lower area.
Then click over No servers available, Click this link to create a new server… Select Apache -> Tomcat v8.5 Server.
Press Next and enter the directory where the server is located and choose JDK installed. Press Finish.
Execute your home page by selecting Run As -> Run on Server.
And finally, our jsp page appears within Eclipse in an embedded browser. Also, you can display the page in your web browser by entering http://localhost:8080/project/index.jsp (remember to have Apache started from Eclipse).
Congratulations!! You have already learned the minimum requirements to set up a web project.