FILS, English Stream, Year 4

Course: Web Application Development

Prof. Luca Dan Serbanati

Prof.Assist. Vlad Posea

 

Fourth laboratory

Web Programming with Servlets

 

  1. Write a HTML page which captures the user’s personal data (fist and last name, birthday, sex, and CNP) by using a form . The form’s action component is a servlet which verifies the user’s data and responds with a welcome page that echoes all data.

 

  1. Write a HTML page which is used repeatedly to capture data on companies (name and business description). Information about a company is encapsulated in a Company object and added to a list companies stored in the server in the session public domain. In the same page there is another form with a submit button List for displaying the company list in a conclusive HTML page. 

 

  1. Use the following Java Beans for manage in a little site employees of some companies:

 

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.