0% found this document useful (0 votes)
16 views5 pages

Maven Dynamic Web Project

This document provides a step-by-step guide to creating a Maven Dynamic Web Project in Eclipse, including setting up the project, modifying the pom.xml to add dependencies for Hibernate ORM, MySQL Connector, Servlet API, and JSP. It also outlines the creation of entity classes, configuration files, servlets, and JSP pages necessary for handling student data. Additionally, it includes instructions for configuring the web.xml file to ensure proper server functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Maven Dynamic Web Project

This document provides a step-by-step guide to creating a Maven Dynamic Web Project in Eclipse, including setting up the project, modifying the pom.xml to add dependencies for Hibernate ORM, MySQL Connector, Servlet API, and JSP. It also outlines the creation of entity classes, configuration files, servlets, and JSP pages necessary for handling student data. Additionally, it includes instructions for configuring the web.xml file to ensure proper server functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Maven Dynamic Web Project :

STEP 1 : To create a web project in Eclipse:

1. Click on "File" in the menu bar, then select "New", and choose "Maven
Project".

2. After clicking "Next", select "Internal" in the catalog options.

3. Type "quickstart" in the filter box and select it.

4. Enter "com.cst" for the Group ID.

5. Enter "Mavenwebproject" for the Artifact ID.

6. Click "Finish" to create the project.

7. Once the project is created, right-click on "Mavenwebproject" in the


Project Explorer.

8. From the context menu, select "Properties".

9. In the Properties window, choose "Project Facets".

10. Check the box next to "Dynamic Web Module".

11. Click on "Apply and Close" to save the changes.

Step : 2 Modify pom.xml

In the Maven project, the dependencies and configurations will be


managed through the pom.xml file.

To add dependencies for Hibernate ORM, MySQL Connector, Servlet


API, and JSP in a Maven project, you need to include the relevant entries
in your pom.xml file. Below is an example of how to structure these
dependencies.
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.6.1.Final</version>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.4.0</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>

Step 3:

· Create Your Entity Class:

 Create an entity class representing the data model. For example, if


you have a student1 class, it should be annotated with Hibernate
annotations.
 Example: student1.java.

· Create Configuration File:

 Create a hibernate.cfg.xml file in the src/main/resources directory


to configure Hibernate settings, including the database connection
details.

Hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>

<hibernate-configuration>
<session-factory>
<property
name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property
>
<property
name="hibernate.connection.url">jdbc:mysql://localhost:3306/cst</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">passwaord1</property>
<property
name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.cst.Mavendynamic.student1" />
</session-factory>
</hibernate-configuration>
· Create Servlets:

 Create servlets to handle requests for inserting and retrieving


students. For example, insertstudent and retrievestudents.
 Ensure these servlets are annotated with @WebServlet.

· Create JSP Pages:

 Create JSP pages for displaying forms and results. For instance,
create insertStudent.jsp for the insertion form and
displayStudents.jsp for displaying student records.
 Example of insertStudent.jsp

Note : if the server is not starting , make the chances in web.xml file by
adding element tag

Web.xml:
<?xml version="1.0" encoding="UTF-8"?>

<element>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" version="5.0">
<servlet>
<description></description>
<display-name>insertstudent</display-name>
<servlet-name>insertstudent</servlet-name>
<servlet-class>com.cst.Mavendynamic.insertstudent</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>insertstudent</servlet-name>
<url-pattern>/insertstudent</url-pattern>
</servlet-mapping>
<display-name>Mavendynamic</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>retrievestudents</display-name>
<servlet-name>retrievestudents</servlet-name>
<servlet-class>com.cst.Mavendynamic.retrievestudents</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>retrievestudents</servlet-name>
<url-pattern>/retrievestudents</url-pattern>
</servlet-mapping>
</web-app>
</element>

You might also like