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:
![Write Student Class with three Properties. The useBean action declares a JavaBean for use in jsp.Write Java application to access JavaBean Properties. Write Student Class with three Properties. The useBean action declares a JavaBean for use in jsp.Write Java application to access JavaBean Properties.](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiTyGWR7_JOD0nj_UHgvvNu2lB6pPEZdVKVgSlD6JEksEyOQ2vbTpmZsskEIBkmaMMlN4Bbmg7viH-G-tNoynmFiotJStppoKauPBzZqMrnB2L9cnjvQPkrj14DbVZynaJgPRmJbtGFk4/w640-h305/j1.png)
![Write Student Class with three Properties. The useBean action declares a JavaBean for use in jsp.Write Java application to access JavaBean Properties. Write Student Class with three Properties. The useBean action declares a JavaBean for use in jsp.Write Java application to access JavaBean Properties.](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL5gERbQB3JH_LIGVmBRp0Z_n_UMdGUygCShv6JvpWNFOlUG6CRZsHx7epwkCb8CGrEFJ8ZKoth5JVNU_6wNfYPn0uK5u0zo03TUJr9jfk0kaaqfDzTVfLCFSSj_BG2h9ZRtTQiH-DHaU/w640-h315/j2.png)
0 Comments