Sunday, July 9, 2017

8. 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>
<title> Regisration </title>
</head>
<body bgcolor="pink">
<h1> <pre> <font size="18pt"> Registration Page </font> </pre> <br>
<form action="StudInfo.jsp" method="post">
<pre>
FirstName : <input type="text" name="firstName" length="30" />
SurName : <input type="text" name="surname" length="30" />
USN : <input type="text" name="usn" length="30" />
Course : <input type="text" name="course" length="30" />
Sem : <input type="text" name="sem" length="30" />
Age : <input type="text" name="age" length="30" />
Address : <input type="text" name="address" length="30" />
<input type ="submit" value="submit" /> <input type ="reset" value="reset"/>
</pre>
<form>
</body>
</html>

StudInfo.jsp

<html>
<head>
<title>
Register User
</title>
</head>
<body>
<jsp:useBean id="stud" scope="session" class="com.Student">
<jsp:setProperty name="stud" property="*" />
</jsp:useBean>
<p> your First Name is: <jsp:getProperty name="stud" property="firstName" />.</p>
<p> Your Last Name is :
<jsp:getProperty name="stud" property="surname" />.</p>
<p> Your USN is :
<jsp:getProperty name="stud" property="usn" />.</p>
<p> Your COURSE Name is :
<jsp:getProperty name="stud" property="course" />.</p>
<p> Your SEM is :
<jsp:getProperty name="stud" property="sem" />.</p>
<p> Your AGE is :
<jsp:getProperty name="stud" property="age" />.</p>
<p> Your Address is :
<jsp:getProperty name="stud" property="address" />.</p>
</body>
</html>

Student.java

package com;
public class Student{
private String firstName;
private String surname;
private String usn;
private String course;
private int sem;
private int age;
private String address;
public String getFirstName(){
return firstName;
}
public String getSurname(){
return surname ;
}
public String getUsn(){
return usn;
}
public String getCourse(){
return course;
}
public int getAge(){
return age;
}
public int getSem(){
return sem;
}
public String getAddress(){
return address;
}
public void setFirstName(String newFirstName)
{
this.firstName =newFirstName;
}
public void setSurname(String newSurname )
{
this.surname =newSurname;
}
public void setUsn(String newUsn)
{
this.usn =newUsn;
}
public void setCourse(String newCourse)
{
this.course =newCourse;
}
public void setSem(int newSem )
{
this.sem = newSem;
}
public void setAge(int newAge )
{
this.age =newAge;
}
public void setAddress(String newAddress )
{
this.address =newAddress;
}
}

1 comment:

  1. Big data service providers should understand the need of Data, and they should work to build more appropriate services to meet the requirements of their clients.

    ReplyDelete