Online Quiz Portal with Servlets and JSP
Online Quiz Portal with Servlets and JSP
Project Objective: Create an Online quiz portal, where users can explore
multiple quiz, attempt the quiz, and save their position on the learder board.
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class DashboardServletClass
*/
public class DashboardServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DashboardServletClass() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
QuizListservice quizService=new QuizListServiceImpl();
List<QuizListBean> TotalQuizlist=[Link]();
[Link]("TotalQuizlist", TotalQuizlist);
if(![Link]()) {
RequestDispatcher dispatcher=
[Link]("[Link]");
[Link](request, response);
}else {
RequestDispatcher dispatcher=
[Link]("[Link]");
[Link](request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
// protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// doGet(request, response);
// }
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class DeleteQuizServlet
*/
public class DeleteQuizServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DeleteQuizServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String quizid=[Link]("quizId");
QuizList quiz=new QuizList();
quiz.setQuiz_id(quizid);
PrintWriter out=[Link]();
QuizListservice quizservice=new QuizListServiceImpl();
boolean delete;
try {
delete = [Link](quiz);
if(delete) {
RequestDispatcher
rd=[Link]("/dashboardpage");
[Link](request, response);
}
} catch (ClassNotFoundException | SQLException e) {
[Link]();
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class GetById
*/
public class GetById extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public GetById() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String quizId=[Link]("quizId");
QuizList quiz=new QuizList();
quiz.setQuiz_id(quizId);
PrintWriter out=[Link]();
QuizListservice quizservice=new QuizListServiceImpl();
List<QuizListBean> TotalQuizlist;
try {
TotalQuizlist = [Link](quiz);
[Link]("TotalQuizlist", TotalQuizlist);
if(![Link]()) {
RequestDispatcher dispatcher=
[Link]("[Link]");
[Link](request, response);
}else {
RequestDispatcher dispatcher=
[Link]("[Link]");
[Link](request, response);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
[Link]();
}
}
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class LoginServletClass
*/
public class LoginServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public LoginServletClass() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String username=[Link]("username");
String password=[Link]("password");
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class QuestionListServletClass
*/
public class QuestionListServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public QuestionListServletClass() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
Questionsservice quizService=new QuestionServiceImpl();
try {
List<QuestionListBean> TotalQuestuinlist =
[Link]();
[Link]("TotalQuizlist", TotalQuestuinlist);
if(![Link]()) {
RequestDispatcher dispatcher=
[Link]("[Link]");
[Link](request, response);
}else {
RequestDispatcher dispatcher=
[Link]("[Link]");
[Link](request, response);
}
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
[Link]();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class SaveQuestionsServlet
*/
public class SaveQuestionsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public SaveQuestionsServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String question=[Link]("questions");
String op1=[Link]("option1");
String op2=[Link]("option2");
String op3=[Link]("option3");
String op4=[Link]("option4");
String crctans=[Link]("correctAnswer");
String quizId=[Link]("quizId");
String wt=[Link]("weightage");
try {
// Call a DAO or service method to save the quiz question to the
database
QuestionsDAO quizDAO = new QuestionDAOImpl();
boolean isSaved = [Link](quiz);
if (isSaved) {
[Link]("[Link]");
} else {
[Link]("[Link]");
}
} catch (Exception e) {
[Link]();
[Link]("[Link]");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
// protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// // TODO Auto-generated method stub
// doGet(request, response);
// }
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class updateServletClass
*/
public class updateServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public updateServletClass() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String quizid=[Link]("quizId");
String quizName=[Link]("quizName");
String quizcatogoty=[Link]("quizCategory");
String quizmarks=[Link]("quizTotalmarks");
int marks=[Link](quizmarks);
QuizList quiz=new QuizList();
quiz.setQuiz_id(quizid);
[Link](quizName);
[Link](quizcatogoty);
[Link](marks);
QuizListservice quizservice=new QuizListServiceImpl();
try {
boolean update=false;
update=[Link](quiz);
if(update) {
RequestDispatcher
rd=[Link]("[Link]");
[Link](request, response);
}
}catch(Exception e) {
[Link]();
}
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Servlet implementation class userLoginServlet
*/
public class userLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public userLoginServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String username=[Link]("username");
String password=[Link]("password");
Users users=new Users();
[Link](username);
[Link](password);
PrintWriter out=[Link]();
UsersService userService=new UserServiceImpl();
try {
boolean auth=[Link](users);
if(auth) {
[Link]("[Link]");
[Link](request, response);
}
}
}catch(AuthenticationException e) {
[Link]("<font color=red> Login Failed");
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public List<Quizz> retrive() throws ClassNotFoundException,
SQLException {
Connection connection =[Link]();
PreparedStatement
prepared=[Link]("select
[Link],q.option1,q.option2,q.option3,q.option4,q.s_no,q.correct_answer,
q.quiz_id from quizz q inner join quiz_list q1 on q.quiz_id=q1.quiz_id");
List<Quizz> question=new ArrayList<>();
Quizz q=new Quizz();
ResultSet rs=[Link]();
while([Link]()) {
[Link]([Link](1));
q.setOption1([Link](2));
q.setOption2([Link](3));
q.setOption4([Link](4));
q.setS_no([Link](5));
q.setCorrect_answer([Link](6));
q.setQuiz_id([Link](7));
[Link](q);
}
return question;
}
@Override
public boolean deleteById(Quizz quizz) throws ClassNotFoundException,
SQLException {
boolean deleteUser=false;
try {
Connection connection=[Link]();
PreparedStatement
statement=[Link]("DELETE FROM quizz WHERE s_no
= ?");
[Link](1, quizz.getS_no());
int rows=[Link]();
if(rows>0) {
deleteUser=true;
}else {
deleteUser=false;
}
}catch(Exception e) {
[Link](e);
}
return deleteUser;
@Override
public List<Quizz> getById(Quizz quizz) throws ClassNotFoundException,
SQLException {
List<Quizz> quizList = new ArrayList<>();
Connection connection=[Link]();
PreparedStatement
statemet=[Link]("SELECT * FROM quizz WHERE s_no
= ?");
[Link](1, quizz.getS_no());
ResultSet result=[Link]();
while([Link]()) {
Quizz q=new Quizz();
q.setQuiz_id([Link]("quiz_id"));
q.setS_no([Link]("s_no"));
[Link]([Link]("questions"));
q.setOption1([Link]("option1"));
q.setOption2([Link]("option2"));
q.setOption3([Link]("option3"));
q.setOption4([Link]("option4"));
q.setCorrect_answer([Link]("correct_answer"));
[Link]([Link]("weightage"));
[Link](q);
}
return quizList;
}
@Override
public boolean update(Quizz questionlist) throws
ClassNotFoundException, SQLException {
boolean updatequiz=false;
Connection connection=[Link]();
PreparedStatement
statement=[Link]("update quizz set
questions=?,option1=?,option2=?,option3=?,option4=?,correct_answer=?,quiz
_id=?,weightage=?");
[Link](1, [Link]());
[Link](2, questionlist.getOption1());
[Link](3, questionlist.getOption2());
[Link](4, questionlist.getOption3());
[Link](5, questionlist.getOption4());
[Link](6, questionlist.getCorrect_answer());
[Link](7, questionlist.getQuiz_id());
[Link](8, [Link]());
int rows=[Link]();
[Link]();
if(rows>0) {
updatequiz=true;
}else {
updatequiz= false;
}
return updatequiz;
}
package [Link];
import [Link];
import [Link];
import [Link];
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public List<QuizList> retrive() throws ClassNotFoundException,
SQLException {
Connection connection=[Link]();
Statement statement=[Link]();
ResultSet result=[Link]("select * from
quiz_list");
List<QuizList> quizlist=new ArrayList<>();
while([Link]()) {
QuizList quiz=new QuizList();
quiz.setQuiz_id([Link](1));
quiz.setS_no([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));
[Link](quiz);
}
[Link]();
return quizlist;
}
@Override
public boolean deleteById(QuizList quiz) throws
ClassNotFoundException, SQLException {
boolean deleteUser=false;
try {
Connection connection=[Link]();
PreparedStatement
statement=[Link]("DELETE FROM quiz_list WHERE
quiz_id = ?");
[Link](1, quiz.getQuiz_id());
int rows=[Link]();
if(rows>0) {
deleteUser=true;
}else {
deleteUser=false;
}
}catch(Exception e) {
[Link](e);
}
return deleteUser;
@Override
public List<QuizList> getById(QuizList quiz) throws
ClassNotFoundException, SQLException {
List<QuizList> quizList = new ArrayList<>();
Connection connection=[Link]();
PreparedStatement
statemet=[Link]("SELECT * FROM quiz_list WHERE
quiz_id = ?");
[Link](1, quiz.getQuiz_id());
ResultSet result=[Link]();
while([Link]()) {
QuizList q=new QuizList();
q.setQuiz_id([Link]("quiz_id"));
q.setS_no([Link]("s_no"));
[Link]([Link]("quizes"));
[Link]([Link]("catagory"));
[Link]([Link]("total_marks"));
[Link](q);
}
return quizList;
}
@Override
public boolean update(QuizList quizList) throws
ClassNotFoundException, SQLException {
boolean updatequiz=false;
Connection connection=[Link]();
PreparedStatement
statement=[Link]("update quiz_list set
quizes=?,catagory=?,total_marks=? where quiz_id=?");
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, quizList.getQuiz_id());
int rows=[Link]();
[Link]();
if(rows>0) {
updatequiz=true;
}else {
updatequiz= false;
}
return updatequiz;
package [Link];
import [Link];
import [Link];
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
}
package [Link];
import [Link];
public QuizList() {}
@Override
public String toString() {
return "QuizList [quiz_id=" + quiz_id + ", s_no=" + s_no + ",
quizes=" + quizes + ", categories=" + catagory
+ ", totalmarks=" + totalmarks + "]";
}
@Override
public int hashCode() {
return [Link](catagory, quiz_id, quizes, s_no, totalmarks);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != [Link]())
return false;
QuizList other = (QuizList) obj;
return [Link](catagory, [Link]) &&
[Link](quiz_id, other.quiz_id)
&& [Link](quizes, [Link]) && s_no ==
other.s_no && totalmarks == [Link];
}
package [Link];
import [Link];
public Quizz() {}
@Override
public String toString() {
return "Quizz [s_no=" + s_no + ", questions=" + questions + ",
option1=" + option1 + ", option2=" + option2
+ ", option3=" + option3 + ", option4=" + option4 + ",
correct_answer=" + correct_answer + ", quiz_id="
+ quiz_id + ", weightage=" + weightage + "]";
}
@Override
public int hashCode() {
return [Link](correct_answer, option1, option2, option3,
option4, questions, quiz_id, s_no, weightage);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != [Link]())
return false;
Quizz other = (Quizz) obj;
return [Link](correct_answer, other.correct_answer) &&
[Link](option1, other.option1)
&& [Link](option2, other.option2) &&
[Link](option3, other.option3)
&& [Link](option4, other.option4) &&
[Link](questions, [Link])
&& [Link](quiz_id, other.quiz_id) && s_no ==
other.s_no
&& [Link](weightage, [Link]);
}
}
package [Link];
import [Link];
public Users() {}
@Override
public String toString() {
return "Users [username=" + username + ", password=" +
password + ", role=" + role + "]";
}
@Override
public int hashCode() {
return [Link](password, role, username);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != [Link]())
return false;
Users other = (Users) obj;
return [Link](password, [Link]) &&
[Link](role, [Link])
&& [Link](username, [Link]);
}
package [Link];
package [Link];
import [Link];
import [Link];
import [Link];
connection=[Link]([Link](),[Link]
Username(),[Link]());
return connection;
}
package [Link];
import [Link];
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public QuestionListBean() {}
}
}
package [Link];
import [Link];
import [Link];
import [Link];
public QuizListBean() {}
@Override
public String toString() {
return "QuizListBean [quizId=" + quizId + ", serialNo=" + serialNo +
", quizNames=" + quizNames
+ ", quizCategories=" + quizCategories + ",
quizTotalmarks=" + quizTotalmarks + "]";
};
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public List<QuestionListBean> retrive() throws ClassNotFoundException,
SQLException {
List<QuestionListBean> QuestionBeanList=new ArrayList<>();
try {
List<Quizz> QuestionList=[Link]();
for(Quizz quiz:QuestionList) {
QuestionListBean QuestionListBean=new
QuestionListBean();
[Link](quiz.getQuiz_id());
[Link]([Link]());
QuestionListBean.setOption1(quiz.getOption1());
QuestionListBean.setOption2(quiz.getOption2());
QuestionListBean.setOption3(quiz.getOption3());
QuestionListBean.setOption4(quiz.getOption4());
[Link](quiz.getS_no());
[Link](quiz.getCorrect_answer());
[Link](QuestionListBean);
}
} catch (ClassNotFoundException e) {
[Link]();
} catch (SQLException e) {
[Link]();
}
return QuestionBeanList;
}
@Override
public boolean deleteById(Quizz quizz) throws ClassNotFoundException,
SQLException {
return [Link](quizz);
}
@Override
public List<QuestionListBean> getById(Quizz quizz) throws
ClassNotFoundException, SQLException {
List<QuestionListBean> quizBeanList=new ArrayList<>();
try {
List<Quizz> quizList=[Link](quizz);
for(Quizz quiz1:quizList) {
QuestionListBean QuestionListBean=new
QuestionListBean();
[Link](quiz1.getQuiz_id());
[Link](quiz1.getS_no());
[Link]([Link]());
QuestionListBean.setOption1(quiz1.getOption1());
QuestionListBean.setOption2(quiz1.getOption2());
QuestionListBean.setOption3(quiz1.getOption3());
QuestionListBean.setOption4(quiz1.getOption4());
[Link](quiz1.getCorrect_answer());
[Link]([Link]());
[Link](QuestionListBean);
}
}catch(ClassNotFoundException e) {
[Link]();
}catch(SQLException e) {
[Link]();
}
return quizBeanList;
}
@Override
public boolean update(Quizz questions) throws ClassNotFoundException,
SQLException {
return [Link](questions);
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
[Link]([Link]());
[Link]([Link]());
[Link](quizListBean);
}
}catch(ClassNotFoundException e) {
[Link]();
}catch(SQLException e) {
[Link]();
}
return quizBeanList;
}
@Override
public boolean update(QuizList quizList) throws
ClassNotFoundException, SQLException {
return [Link](quizList);
}
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
package [Link];
import [Link];
import [Link];
}
///properties
///#connectivity information for mySQL
driver=[Link]
url=jdbc:mysql://localhost:3306/UsersDB
username=root
password=Phani@06
.form-container {
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
width: 400px;
margin-top: 20px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
label {
font-size: 16px;
color: #333;
margin-top: 10px;
display: block;
}
input[type="text"], select {
width: 100%;
padding: 10px;
margin-top: 5px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="radio"] {
margin-right: 10px;
}
.options {
margin-bottom: 15px;
}
button {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
.footer {
text-align: center;
font-size: 12px;
color: #777;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="form-container">
<h1>Create a New Question</h1>
<label>Option 2</label>
<input type="text" name="option2" required>
<label>Option 3</label>
<input type="text" name="option3" required>
<label>Option 4</label>
<input type="text" name="option4" required>
<label>Correct Answer</label>
<input type="text" name="correctAnswer" required>
<label>QuizID</label>
<input type="text" name="quizId" required>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<style>
/* General body styling */
body {
font-family: 'Arial', sans-serif;
background-color: #eaeff1;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
/* Heading style */
.login-container h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
/* Label style */
.login-container label {
display: block;
font-size: 14px;
color: #555;
margin-bottom: 6px;
}
.login-container p a {
color: #007bff;
text-decoration: none;
}
.login-container p a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<form action="adminlogin" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username"
placeholder="Enter your username" required>
<label for="password">Password</label>
<input type="password" id="password" name="password"
placeholder="Enter your password" required>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Dashboard Table</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 20px;
}
table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
background-color: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #4CAF50;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
.button {
padding: 6px 12px;
margin: 5px;
font-size: 14px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
text-decoration: none;
}
.edit-button {
background-color: #4CAF50;
}
.delete-button {
background-color: #f44336;
}
.edit-button:hover {
background-color: #45a049;
}
.delete-button:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<table cellspacing="2" cellpadding="2" border="2">
<thead>
<tr>
<th>Quiz Id</th>
<th>Quiz Name</th>
<th>Quiz category</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<c:forEach items="${TotalQuizlist}" var="quizlist">
<tr>
<td><c:out value="${[Link]}"/></td>
<td><c:out value="${f:toUpperCase([Link])}"/></td>
<td><c:out value="${[Link]}"/></td>
<td>
<!-- Edit and Delete buttons -->
<a href="getbyid?quizId=${[Link]}" class="button edit-
button">Edit</a>
<a href="deletequiz?quizId=${[Link]}" class="button
delete-button">Delete</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
.form-container {
width: 50%;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"], select {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
.button {
display: inline-block;
padding: 10px 20px;
margin-top: 20px;
font-size: 16px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
text-decoration: none;
background-color: #4CAF50;
}
.button:hover {
background-color: #45a049;
}
.cancel-button {
background-color: #f44336;
margin-left: 10px;
}
.cancel-button:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<div class="form-container">
<h2>Edit Quiz</h2>
<!-- Accessing the first element of TotalQuizlist -->
<c:forEach items="${TotalQuizlist}" var="quiz" varStatus="status"
begin="0" end="0">
<form action="updatequiz" method="post">
<!-- Quiz ID (read-only) -->
<div class="form-group">
<label for="quizId">Quiz ID</label>
<input type="text" id="quizId" name="quizId" value="$
{[Link]}" readonly>
</div>
<div class="form-group">
<label for="quizTotalmarks">Quiz total</label>
<input type="text" id="quizTotalmarks" name="quizTotalmarks"
value="${[Link]}" required>
</div>
<!-- Submit and Cancel buttons -->
<button type="submit" class="button">Update</button>
<a href="[Link]" class="button cancel-button">Cancel</a>
</form>
</c:forEach>
</div>
</body>
</html>
</body>
</html>
<!DOCTYPE html>
<html lang="en" method="post">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
}
.sidebar {
width: 200px;
background-color: #333;
height: 100vh;
color: white;
padding-top: 20px;
position: fixed;
transition: width 0.3s ease;
}
.sidebar a {
text-decoration: none;
color: white;
padding: 10px 15px;
display: block;
}
.sidebar a:hover {
background-color: #575757;
}
.sidebar .submenu {
display: none;
margin-left: 20px;
}
.sidebar .submenu a {
padding-left: 30px;
}
.content {
margin-left: 220px;
padding: 20px;
width: 100%;
}
h1 {
text-align: center;
}
.dashboard-links {
margin-top: 20px;
}
.dashboard-links a {
display: block;
margin: 10px 0;
}
</style>
</head>
<body>
<script>
// Toggle the visibility of the submenu
function toggleSubmenu(id) {
var submenu = [Link](id);
if ([Link] === "block") {
[Link] = "none";
} else {
[Link] = "block";
}
}
// Function to load content dynamically into the content div (optional)
function loadContent(page) {
// Define the URL based on the page clicked
const url = "[Link] + page;
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Dashboard Table</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 20px;
}
table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
background-color: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #4CAF50;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
.button {
padding: 6px 12px;
margin: 5px;
font-size: 14px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
text-decoration: none;
}
.edit-button {
background-color: #4CAF50;
}
.delete-button {
background-color: #f44336;
}
.edit-button:hover {
background-color: #45a049;
}
.delete-button:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<table cellspacing="2" cellpadding="2" border="2">
<thead>
<tr>
<th>S No</th>
<th>Question</th>
<th>Option-1</th>
<th>Option-2</th>
<th>Option-3</th>
<th>Option-4</th>
<th>Correct Answer</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="${TotalQuizlist}" var="quizlist">
<tr>
<td><c:out value="${[Link]}"/></td>
<td><c:out value="${[Link]}"/></td>
<td><c:out value="${quizlist.Option1}"/></td>
<td><c:out value="${quizlist.Option2}"/></td>
<td><c:out value="${quizlist.Option3}"/></td>
<td><c:out value="${quizlist.Option4}"/></td>
<td><c:out value="${[Link]}"/></td>
<td>
<!-- Edit and Delete buttons -->
<a href="deletebyid?quizId=${[Link]}" class="button edit-
button">Edit</a>
<a href="deletequestion?quizId=${[Link]}" class="button
delete-button">Delete</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
/* Body styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
/* Container styling */
.container {
width: 80%;
margin: 20px;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
}
/* Heading styling */
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
/* Table styling */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
padding: 10px;
text-align: left;
border: 1px solid #ddd;
}
th {
background-color: #f9f9f9;
td {
background-color: #f9f9f9;
color: black;
}
/* Button styling */
.btn-start {
padding: 8px 15px;
background-color: red;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
text-align: center;
}
.btn-start:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h1>Quiz List</h1>
<table>
<thead>
<tr>
<th>Sr No</th>
<th>Quiz Title</th>
<th>Category</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="${TotalQuizlist}" var="quizlist">
<tr>
<td><c:out value="${[Link]}"/></td>
<td><c:out value="${f:toUpperCase([Link])}"/></td>
<td><c:out value="${[Link]}"/></td>
<td>
<!-- Edit and Delete buttons -->
<a href="startquiz?quizId=${[Link]}" class="btn-
start">Start</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<script>
// JavaScript function to handle the "Start" button click
function startQuiz(quizId) {
alert('Starting quiz ' + quizId);
// You can replace this with redirection to the quiz page or logic to load the
quiz
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<style>
/* Basic reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Body styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
/* Login container */
.login-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
/* Heading styling */
h2 {
margin-bottom: 20px;
font-size: 24px;
color: #333;
}
.textbox input {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
outline: none;
}
/* Button styling */
.btn {
width: 100%;
padding: 10px;
font-size: 18px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.btn:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-box">
<div class="user-icon">
<img src="[Link]" alt="User Icon">
</div>
<h2>Login</h2>
<form action="userlogin" method="post">
<div class="textbox">
<input type="text" name="username" placeholder="Username"
required>
</div>
<div class="textbox">
<input type="password" name="password" placeholder="Password"
required>
</div>
<button type="submit" class="btn">Login</button>
</form>
</div>
</div>
</body>
</html>