

- #APACHE TOMCAT TUTORIAL HOW TO#
- #APACHE TOMCAT TUTORIAL UPDATE#
- #APACHE TOMCAT TUTORIAL CODE#
- #APACHE TOMCAT TUTORIAL DOWNLOAD#
This is because we haven’t created any Java servlet to handle this request. In this case, we specify a path which is relative to the application and it points to a Java servlet which we will create in the next section.Save the file and refresh the browser, you will see: Try to enter something in the text field and click Call Servlet, we get a 404 error page like this: Don’t worry. The actionattribute of the form specifies the URL handles this form’s submission.
#APACHE TOMCAT TUTORIAL CODE#
This HTML code adds a form with a text field and a submit button to the page.

Add the following code between the tags of the page: Hello JSP and Servlet! The idea is adding a web form and on submit, the form will be processed by the servlet.
#APACHE TOMCAT TUTORIAL UPDATE#
Update the JSP Page (Adding Form)Next, let’s update the JSP page to work with a Java servlet. Google Chrome and enter the following URL (as shown in the internal web browser): Congratulations!- Another way is opening an external browser e.g. This will open an internal web browser inside the IDE like this: If you see the page displays “Hello JSP and Servlet!”, that means the web application is up and running successfully. Tomcat will be in Started state after few seconds and you see the last line in the Console view is something like this: INFO: Server startup in 1239 msNow we can test the JSP page either by:- Right click on the project, select Run As > Run on Server and click Finish in the Run on Server dialog. If you haven’t added Tomcat server to Eclipse, follow this tutorial to add Apache Tomcat to the IDE.To deploy the project on Tomcat, simply drag the project from the Project Explorer view to Servers view, which results in the following screenshot: Right click on the server and select Start. Testing the JSP PageNow, let’s test the JSP page to see if the server works normally.


Update it with the following code: Īs you can see, this page simply uses HTML code to display the text “Hello JSP and Servlet!”. Enter index.jspas the file name in the New JSP File dialog: Click Finish and you see Eclipse created the index.jspfile under the WebContentdirectory. Creating a JSP PageRight click on the project and select New > JSP File.
#APACHE TOMCAT TUTORIAL DOWNLOAD#
Save the pom.xmlfile and Maven will download the dependent JAR files in few seconds, as you can see under the Libraries section of the project: 3. You can see these are two dependencies for Servlet API 3.1.0 and JSP API 2.3.1. Open it in XML mode and put the following code between the and elements: Now you see the pom.xmlfile created in the project. The Create New POM dialog appears, enter the following information: Note that the Group Id will be used as the main package for our Java code. To do so, right click on the project and select Configure > Convert to Maven project. Adding Dependencies for Serlvet and JSP in Maven’s Project FileNow, we need to add Maven as a build manager for our project. Click Finish.Eclipse creates the project that looks something like this: This is a typical Java EE project. But since Servlet 3.0 can be declared with annotations, we can choose not to create this XML file. Here we can check the option Generate web.xml deployment descriptor to create web.xmlfile.
#APACHE TOMCAT TUTORIAL HOW TO#
