Creating a project and setting up Maven dependencies

We will perform the following steps to create the Maven project for our application:

  1. Create a Maven web project as described in Chapter 2, Creating a Simple JEE Web Application.
  2. Name the project CourseManagementJDBC.
  3. Add dependencies for servlet and JSP, but do not add a dependency for JSF.
  1. To add the dependency for JSTL, open pom.xml and go to the Dependencies tab. Click on the Add... button. Type javax.servlet in the search box and select jstl:
Figure 4.10: Adding a dependency for jstl
  1. Add the dependency for the MySQL JDBC driver too:
    Figure 4.11: Adding dependency for the MySQL JDBC driver

    Here is the pom.xml file after adding dependencies:

    <project xmlns="http://maven.apache.org/POM/4.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>packt.book.jee.eclipse</groupId> <artifactId>CourseManagementJDBC</artifactId> <version>1</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.9-rc</version> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> </dependencies> </project>

    Note that the dependencies for servlet and JSP are marked as provided, which means that they will be provided by the web container (Tomcat) and will not be packaged with the application.

    The description of how to configure Tomcat and add a project to it is skipped here. Refer to Chapter 2, Creating a Simple JEE Web Application, for these details. This section will also not repeat information on how to run JSP pages and about JSTL that were covered in Chapter 2, Creating a Simple JEE Web Application.

    ..................Content has been hidden....................

    You can't read the all page of ebook, please click here login for view all page.
    Reset
    18.118.128.105