FILS,
English Stream, Year 4
Course:
Web Application Development
Prof. Luca Dan Serbanati
Prof.Assist. Vlad
Posea
Fourth laboratory
Web Programming with Servlets
import javax.servlet.*;
import javax.servlet.http.*;
import
java.io.*;
public
class NameBean {
private String firstName
;
private String lastName;
public NameBean()
{}
public NameBean(String
firstName, String lastName)
{
setFirstName(firstName);
setLastName(lastName);
}
public String getFirstName()
{
return(firstName);
}
public void setFirstName(String
newFirstName) {
firstName = newFirstName;
}
public String getLastName()
{
return(lastName);
}
public void setLastName(String
newLastName) {
lastName = newLastName;
}
}
public
class CompanyBean {
private String companyName;
private String business;
public CompanyBean(String
companyName, String business) {
setCompanyName(companyName);
setBusiness(business);
}
public String getCompanyName()
{ return(companyName); }
public void setCompanyName(String
newCompanyName) {
companyName = newCompanyName;
}
public String getBusiness()
{ return(business); }
public void setBusiness(String
newBusiness) {
business = newBusiness;
}
}
import javax.servlet.*;
import javax.servlet.http.*;
import
java.io.*;
public
class EmployeeBean {
private NameBean
name;
private CompanyBean
company;
public EmployeeBean(NameBean name, CompanyBean
company) {
setName(name);
setCompany(company);
}
public NameBean getName() { return(name); }
public void setName(NameBean newName) {
name = newName;
}
public CompanyBean getCompany() { return(company); }
public void setCompany(CompanyBean newCompany) {
company = newCompany;
}
}
The user can insert
persons and companies and then associates each person with a company. Finally a
list of all persons with their company and a list of all companies with their
employees can be asked.
Hint:
1. Find information on
JavaBeans in the course lectures slides.
2. Use the session public domain for store three Map-s: Persons, Companies and Employees. Search the persons and companies in these maps.