Write a JAVA JSP Program to get student
information through a HTML and create a JAVA Bean Class, populate Bean and
display the same information through another JSP.
//index.jsp
<html>
<head> Student
Info Entry Form </head>
<body>
<form action
="jsp8.jsp" method = "post">
Registration
Number : <input type = "text" name = "regno" />
<br>
Name :
<input type = "text" name = "uname" />
<br>
Address
:<input type = "text" name = "address" />
<br>
<input
type ="submit" value ="Register" />
</form>
</body>
</html>
//jsp8.jsp
<html>
<body>
<jsp:useBean id="std" scope="request"
class="ourbeans.Student" />
<jsp:setProperty name="std" property="*"/>
<jsp:forward page="welcomeinfo.jsp"/>
</body>
</html>
//welcomeinfo.jsp
<html>
<body>
<h1>Welcome
Your Info </h1>
<jsp:useBean
id="std" scope="request"
class="ourbeans.Student"/>
User Name :
<jsp:getProperty name="std"
property="uname"/><br>
Registration
Number : <jsp:getProperty name="std"
property="regno"/><br>
Address :
<%out.print(std.getaddress());%>
</body>
</html>
//Student.java
package ourbeans;
public class Student
{
public
String uname;
public int
regno;
public
String address;
public
Student(){}
public void
setuname(String s)
{uname
= s;}
public
String getuname()
{return
uname;}
public void
setregno(int rg)
{regno=rg;}
public int
getregno()
{return
regno;}
public void
setaddress(String ad)
{address
= ad;}
public
String getaddress()
{return
address;}
}
OUTPUT
No comments:
Post a Comment