Wad Assn2.1
Wad Assn2.1
Wad Assn2.1
717821F148
III-yr IT –A
WEB APPLICATION
DEVELOPMENT USING JAVA
21PE18
ASSIGNMENT - 2
The Mexican Restaurant Website
Source code:
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
// Database connection
Connection connection = null;
PreparedStatement statement = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection(JDBC_URL,
DB_USER, DB_PASSWORD);
out.println("<html><head><title>User
Registration</title></head><body>");
out.println("<h1>User Registration</h1>");
out.println("<form method='post' action='UserServlet'>");
out.println("Name: <input type='text' name='name'><br>");
out.println("Email: <input type='text' name='email'><br>");
out.println("Password: <input type='password'
name='password'><br>");
out.println("<input type='submit' value='Register'>");
out.println("</form>");
out.println("</body></html>");
}
out.println("<html><head><title>User
Registration</title></head><body>");
out.println("<h1>User Registration</h1>");
out.println("<p style='color: red;'>" + errorMessage +
"</p>");
out.println("<form method='post' action='UserServlet'>");
out.println("Name: <input type='text' name='name'><br>");
out.println("Email: <input type='text' name='email'><br>");
out.println("Password: <input type='password'
name='password'><br>");
out.println("<input type='submit' value='Register'>");
out.println("</form>");
out.println("</body></html>");
}
out.println("<html><head><title>Registration
Successful</title></head><body>");
out.println("<h1>Registration Successful</h1>");
out.println("<p>Your account has been created
successfully.</p>");
out.println("</body></html>");
}
}
OUTPUT