Vote.html
<html>
<head></head>
<body>
<h2>Enter Your Details</h2>
<form action="vote.jsp" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required><br><br>
<input type="submit" value="Check">
</form>
</body>
</html>
vote.jsp
<%@ page language="java" contentType="text/html" %>
<html>
<head>
<title>Voter Eligibility Result</title>
</head>
<body>
<%
String name = request.getParameter("name");
String ageStr = request.getParameter("age");
int age = 0;
if (ageStr != null && !ageStr.isEmpty()) {
age = Integer.parseInt(ageStr);
}
if (name != null && !name.isEmpty()) {
if (age >= 18) {
%>
<h2>Hello, <%= name %>! You are eligible to vote.</h2>
<%
} else {
%>
<h2>Sorry, <%= name %>. You are not eligible to vote.</h2>
<%
}
} else {
%>
<h2>Please enter your name.</h2>
<%
}
%>
<a href="vote.html">Go Back</a>
</body>
</html>