Index.html
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form name="frm" method="post" action="display1.jsp">
<b>Name:</b><input type="text" name="txt"/><br/>
<b>Roll No.:</b><input type="text" name="txt1"/><br/>
<b>Class:</b><input type="text" name="txt2"/><br/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
Display1.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
int r = Integer.parseInt(request.getParameter("txt1"));
String n = request.getParameter("txt");
String c = request.getParameter("txt2");
%>
<jsp:useBean id = "s1" class = "pack.student">
<jsp:setProperty name="s1" property="rollno" value="<%=r%>"/>
<jsp:setProperty name="s1" property="name" value="<%=n%>"/>
<jsp:setProperty name="s1" property="className" value="<%=c%>"/>
</jsp:useBean>
<p>
<b>Name:
<jsp:getProperty name="s1" property = "name"/></b>
</p>
<p>
<b>Roll No.:
<jsp:getProperty name="s1" property = "rollno"/></b>
</p>
<p>
<b>Class:
<jsp:getProperty name="s1" property = "className"/></b>
</p>
</body>
</html>
student.java
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
int r = Integer.parseInt(request.getParameter("txt1"));
String n = request.getParameter("txt");
String c = request.getParameter("txt2");
%>
<jsp:useBean id = "s1" class = "pack.student">
<jsp:setProperty name="s1" property="rollno" value="<%=r%>"/>
<jsp:setProperty name="s1" property="name" value="<%=n%>"/>
<jsp:setProperty name="s1" property="className" value="<%=c%>"/>
</jsp:useBean>
<p>
<b>Name:
<jsp:getProperty name="s1" property = "name"/></b>
</p>
<p>
<b>Roll No.:
<jsp:getProperty name="s1" property = "rollno"/></b>
</p>
<p>
<b>Class:
<jsp:getProperty name="s1" property = "className"/></b>
</p>
</body>
</html>
OUTPUT:
0 Comments