Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
372
Chapter 15 Integrating Servlets and JSP
Listing 15.5 TravelCustomer.java (continued)
  private String replaceIfMissing(String value,
                                  String defaultValue) {
    if ((value != null) && (value.length() > 0)) {
      return(value);
    } else {
      return(defaultValue);
    }
  }
  public static TravelCustomer findCustomer
                                 (String emailAddress,
                                  TravelCustomer[] customers) {
    if (emailAddress == null) {
      return(null);
    }
    for(int i=0; i
      String custEmail = customers[i].getEmailAddress();
      if (emailAddress.equalsIgnoreCase(custEmail)) {
        return(customers[i]);
      }
    }
    return(null);
  }    
}
Listing 15.6 TravelData.java 
package coreservlets;
/** This class simply sets up some static data to
 *  describe some supposed preexisting customers.
 *  Use a database call in a real application. See
 *  CSAJSP Chapter 18 for many examples of the use
 *  of JDBC from servlets.
 */
public class TravelData {
  private static FrequentFlyerInfo[] janeFrequentFlyerData =
    { new FrequentFlyerInfo("Java Airways", "123 4567 J"),
      new FrequentFlyerInfo("Delta", "234 6578 D") };
  private static RentalCarInfo[] janeRentalCarData =
    { new RentalCarInfo("Alamo", "345 AA"),
      new RentalCarInfo("Hertz", "456 QQ H"),
      new RentalCarInfo("Avis", "V84 N8699") };
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved