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. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |