0% found this document useful (0 votes)
93 views

Design A Student Bean Class With Getter/setters For The Student Details Like First Name, Last Name and Age Access The Above Bean Class in JSP

1. A Student bean class is created with getter and setter methods for student details like first name, last name, age. 2. A JSP page uses this Student bean class to set property values and display them using getProperty methods. 3. A HTML form collects user input for student details which are then set on a student object and displayed on the JSP page using the bean's getter and setter methods.

Uploaded by

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

Design A Student Bean Class With Getter/setters For The Student Details Like First Name, Last Name and Age Access The Above Bean Class in JSP

1. A Student bean class is created with getter and setter methods for student details like first name, last name, age. 2. A JSP page uses this Student bean class to set property values and display them using getProperty methods. 3. A HTML form collects user input for student details which are then set on a student object and displayed on the JSP page using the bean's getter and setter methods.

Uploaded by

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

Cia-6

 JavaBeans:-

1. Design a Student Bean class with getter/setters for the Student


details like first name, last name and age; Access the above
bean class in JSP.

 Newhtml.html
<html>
<body>
<form method="post" action="index.jsp">
First Name:<input type="text" name="firstname"/>
Last Name:<input type="text" name="lastname"/>
Age:<input type="text" name="Age"/>
USN:<input type="text" name="usn"/>
Email_ID:<input type="text" name="email_id"/>
Course:<input type="text" name="course"/>
<input type="submit" value="go"/>
</form>
</body>
</html>

 Index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Getter and Setter method</title>
</head>
<body>
<center>
<p> GET AND SET EXAMPLES </p>
<jsp:useBean id="students" class="p1.student">
<jsp:setProperty name="students" property="firstName"
value="KHYATI"/>
<jsp:setProperty name="students" property="lastName"
value="PARIKH"/>
<jsp:setProperty name="students" property="age"
value='22'/>
<jsp:setProperty name="students" property="usn"
value='18MSRIT010'/>
<jsp:setProperty name="students" property="email_id"
value='[email protected]'/>
<jsp:setProperty name="students" property="course"
value='MSCIT'/>
<p> First Name: <jsp:getProperty name="students"
property="firstName"/> </p>
<p> Last Name: <jsp:getProperty name="students"
property="lastName"/>
</p>
<p>Age:<jsp:getProperty name="students" property="age"/>
</p>
<p>USN:<jsp:getProperty name="students"
property="usn"/>
</p>
<p>EMail_ID:<jsp:getProperty name="students"
property="email_id"/>
</p>
<p>Course:<jsp:getProperty name="students" property="course"/>
</p>
</jsp:useBean>
</center>
</body>
</html>

 Student.java
package p1;
import java.beans.*;
import java.io.Serializable;
public class student implements java.io.Serializable
{
private String firstName = null;
private String lastName = null;
private int age = 0;
private String usn = null;
private String email_id = null;
private String course = null;

public student() {
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public int getAge(){
return age;
}
public String getUsn(){
return usn;
}
public String getEmail_id(){
return email_id;
}
public String getCourse(){
return course;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public void setAge(int age)
{
this.age = age;
}
public void setUsn(String usn)
{
this.usn = usn;
}
public void setEmail_id(String email_id)
{
this.email_id = email_id;
}
public void setCourse(String course)
{
this.course = course;
}
}

You might also like