Exp.
No : 04 Web Application With
Date : / /2024 Maven
AIM :
To design a Maven-based web application that displays event details and allows user registration using
HTML and Servlets.
PROCEDURE :
1. Create a Maven Web Application:
• Generate the Maven web application structure:
mvn archetype:generate -DgroupId=[Link] -DartifactId=my-webapp -
DarchetypeArtifactId=maven- Darchetype-webapp -DinteractiveMode=false
2. *Add HTML Pages*:
• Create [Link] for displaying event details and linking to the registration form.
• Create [Link] to implement the registration form.
3. *Develop a Servlet*:
• Implement a servlet class (HelloServlet) to process requests and respond with dynamic content.
4. *Build and Deploy*:
• Build the project using Maven:
$ mvn clean package
• Deploy the .war file to a servlet container such as Apache Tomcat.
5. Access the Web Application:
• Open a web browser and navigate to:
• Events Page: [Link]
• Registration Form: [Link]
• Servlet Response: [Link]
Directory Structure:
|my-webapp/
├── src
│ ├── main
│ │ ├── java
│ │ │ └── [Link]
│ │ ├── resources
│ │ └── webapp
│ │ ├── [Link]
│ │ ├── [Link]
│ │ └── WEB-INF
│ │ └── [Link]
└── target/
Program:
1. [Link]: Event Details Page
<!DOCTYPE html>
<html>
<head>
<title>Events</title>
<link rel="icon" href="images/[Link]">
</head>
<body bgcolor="black" style="color: white;">
<h1 align="center">Upcoming Events 📆</h1>
<h4 align="center">Don't miss any of your events. Here are the important events you have registered
for!</h4>
<hr>
<p align="center"><img src="images/[Link]" alt="Event Image"></p>
<h1 align="center">Photo Gallery Event</h1>
<h2 align="center">Free Entry | Free Food | Pets are Not Allowed</h2>
<p align="center"><img src="images/[Link]" alt="Gallery Image"></p>
<p align="center"><a href="[Link]">Register Now!</a></p>
<h1 align="center">Contact</h1>
<h2 align="center">+91 65926526899 | eventcollab@[Link]</h2>
<h3 align="center">9th Street Avenue Park, Salem, 636304</h3>
</body>
</html>
3. [Link]: Registration Form
<!DOCTYPE html>
<html>
<head>
<title>Register Form</title>
<style>
label {
color: rgb(16, 23, 16);
font-family: Cambria, Georgia, serif;
}
</style>
</head>
<body background="images/[Link]">
<h1 align="center" style="color: blue;">Registration Form</h1>
<center>
<fieldset>
<legend><h2 style="color: rgb(188, 79, 192)">Register</h2></legend>
<form>
<table>
<tr>
<td><label>NAME:</label></td>
<td><input type="text" placeholder="Your name" style="background: lightblue;"></td>
</tr>
<tr>
<td><label>PASSWORD:</label></td>
<td><input type="password" style="background: lightblue;"></td>
</tr>
<tr>
<td><label>DOB:</label></td>
<td><input type="date" style="background: lightblue;"></td>
</tr>
<tr>
<td><label>ADDRESS:</label></td>
<td><textarea cols="40" rows="5" style="background: lightblue;"></textarea></td>
</tr>
<tr>
<td><label>GENDER:</label></td>
<td>
<input type="radio" name="gender">Male
<input type="radio" name="gender">Female
</td>
</tr>
<tr>
<td><label>COURSE:</label></td>
<td>
<select style="background: lightblue;">
<option value="1">DLD</option>
<option value="2">DSA</option>
<option value="3">FDS</option>
</select>
</td>
</tr>
<tr>
<td><label>FILES:</label></td>
<td><input type="file" style="background: lightblue;"></td>
</tr>
<tr>
<td colspan="2">
<button style="background: lightblue;">SUBMIT</button>
<button style="background: lightblue;">RESET</button>
</td>
</tr>
</table>
</form>
</fieldset>
</center>
</body>
</html>
4. [Link]: Servlet Class
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
[Link]("text/html");
[Link]().println("<h1>Welcome to the Event Web Application!</h1>");
}
}
5. [Link]: Servlet Mapping
<web-app xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link] [Link]
app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>
Preparation
Observation
Output
Viva
Record
Total
RESULT:
Hence the Web application created using maven servelets has been implemented and the output has
been verified successfully.
OUTPUT: