Professional Documents
Culture Documents
19mid0017 VL2022230104097 Ast03
19mid0017 VL2022230104097 Ast03
Name: Mothishwaran C.
Slot: L53+L54
Question: Assume a driver (user) is caught by a police while violating the driving rules. Then, the police is providing him/her a
login portal and asked the driver to submit the name and age. If the age is below 18 then the police has to report as “ Warning: You are
not eligible for Driving”. Otherwise, each time the user is caught, then the police has a count on the particular user. If the user is caught
third time then the police cancel his/her driving license, reported as ”DL CANCELLED ” along with date and time. Demonstrate for atleast
three users (drivers).These activities are recorded between 5:40 PM to 6:40 PM. Develop as application for the above said scenario of
driving rule violation with suitable front-end using JSP.
Index.html:
<html>
<head>
<meta charset="UTF-8">
<style>
body{
background-color: #FBAB7E;
display: flex;
justify-content: center;
align-items: center;
.content{
width: 40%;
height:60%;
padding: 10px;
background-color: #fff;
</style>
</head>
<body>
<div class="content">
<center>
<hr>
<table>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</form>
</center>
</div>
</body>
</html>
DLChecker.jsp:
<%--
Document : DL_Checker
Author : Mothish
--%>
<%@page import="java.time.LocalDateTime"%>
<%@page import="java.time.format.DateTimeFormatter"%>
<!DOCTYPE html>
<html>
<head>
<title>JSP Page</title>
<style>
body{
background-color: #FBAB7E;
display: flex;
justify-content: center;
align-items: center;
.content{
width: 40%;
height:60%;
margin:15%;
padding: 10px;
background-color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.button {
background-color: #4CAF50;
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
</style>
</head>
<body>
<div class="content">
<%
String uname=request.getParameter("name");
String udate=uname+"_date";
if(age<18){
out.println("Hey "+uname+" You are not eligible!");
}else{
if(caught_count==null){
caught_count=1;
}else{
caught_count+=1;
if(caught_count<3){
else if(caught_count==3){
String dtime=String.valueOf(datetime.format(formatter));
session.setAttribute(udate,dtime);
}else{
}}
session.setAttribute(uname,caught_count);
session.setMaxInactiveInterval(60*60);
out.println("<br><div><hr><div>");
%>
</div>
</body>
</html>
Output:
User-1 :
User-1 is Elon, 17. So he got as follows.
User-2:
User -2 is Musk. He is above 18 and he got caught for 3 times.
User-3:
User-3 is Moss, 22. He got caught for 3rd time and his DL was cancelled.
User :2 re-checked
User 2, Musk re-checked after 1 minute