0% found this document useful (0 votes)
16 views3 pages

Advanced Java and J2EE Lab 7

Uploaded by

Abhijith Hari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Advanced Java and J2EE Lab 7

Uploaded by

Abhijith Hari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ADVANCED JAVA AND J2EE LAB 7

ABHIJITH H
AM.SC.U3CSC19001

A servelet should receive a parameter from JSP page and process it.

a. index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<title>Session Management Example</title>
</head>
<body>
<form method="post" action="First.jsp">
<font size=5>Enter your name<input type="text" name="name"></font><br><br>
<font size=5>Enter your password<input type="password" name="password">
</font><br><br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

b. first.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<%
String name = request.getParameter("name"); String password
= request.getParameter("password"); if
(name.equals("amrita") && password.equals("1234")) {
session.setAttribute("username", name);
response.sendRedirect("Second.jsp");
} else {
response.sendRedirect("index.jsp");
}
%>
</html>
c. second.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello <%= session.getAttribute("username") %>
</body>
</html>

OUTPUT

You might also like