Exp 22
Exp 22
Exp 22
loginpage.html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<h2>User Login</h2>
<form
action="http://localhost:8080/examples/servlets/servlet/AthonticationServlet
" method="POST">
User Name: <input type="text" name="username" required><br>
Password: <input type="password" name="password" required><br>
<input type="submit" value="Login">
</form>
</body>
</html>
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
XIII. Exercise
1. Servlet Program to Retrieve Data from List and Radio Button
HTML Form for List and Radio Buttons (listRadio.html)
<!DOCTYPE html>
<html>
<head>
<title>Selection Form</title>
</head>
<body>
<h2>Select Your Preferences</h2>
<form
action="http://localhost:8080/examples/servlets/servlet/SelectionServlet"
method="POST">
<label for="color">Choose your favorite color:</label>
<select name="color">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
</select><br><br>
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
out.println("<h2>Your Preferences</h2>");
out.println("<p>Favorite Color: " + color + "</p>");
out.println("<p>Gender: " + gender + "</p>");
out.close();
}
}
<!DOCTYPE html>
<html>
<head>
<title>Student Marks Submission</title>
</head>
<body>
<h2>Submit Your Marks</h2>
<form
action="http://localhost:8080/examples/servlets/servlet/MarksServlet"
method="POST">
Enter Marks: <input type="number" name="marks" required><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
out.close();
}
}
Outputs: