home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / PHEnterInfo.java < prev    next >
Text File  |  1998-09-13  |  2KB  |  71 lines

  1. package symantec.sourcebook.servlet;
  2. import java.io.*;
  3. import javax.servlet.*;
  4. import javax.servlet.http.*;
  5.  
  6. public class PHEnterInfo extends PageHandler 
  7. {
  8.    
  9.    private final static String PAGENAME = PAGEBASE + "enterinfo.html";
  10.    int pagenumber = ESDServlet.VERIFYINFO_PAGE_NUM;
  11.  
  12.    public PHEnterInfo()
  13.    {
  14.     
  15.      
  16.    }
  17.    
  18.    public String pageName()
  19.    {
  20.         return PAGENAME;
  21.    }
  22.    
  23.    public int nextPage()
  24.    {
  25.         return pagenumber;
  26.    }
  27.    
  28.    
  29.     public Object validate(ServletConfig config,HttpServletRequest request,HttpServletResponse response) 
  30.     {
  31.         PageData pageData = new PageData(config,request,response);
  32.         
  33.         String errorText = "";
  34.  
  35.         // get information from the form
  36.         
  37.         String name   = getParameter(request,"name","");
  38.         String email  = getParameter(request,"email","");
  39.         String address= getParameter(request,"address","");
  40.         String city   = getParameter(request,"city","");
  41.         String company= getParameter(request,"company","");
  42.         String state  = getParameter(request,"state","");
  43.         String country= getParameter(request,"country","");
  44.         String zip    = getParameter(request,"zip","");
  45.         String phone  = getParameter(request,"phone","");
  46.         
  47.         // do some sanity checks
  48.         
  49.         if(name.length() < 2)   errorText += "Please enter your full name in the name field<br>";
  50.         if(email.length() < 5)  errorText +="Your e-mail address is required.  (It will not be sold to spammers)<br>";
  51.         if(address.length() < 2)errorText += "Please provide your full mailing address<br>";
  52.         if(city.length() < 2)   errorText +="Please include a city in your address<br>";
  53.         
  54.         // if it looks bad, bail
  55.  
  56.         if(errorText.length() > 0) 
  57.         {
  58.             pagenumber = ESDServlet.ENTERINFO_PAGE_NUM;
  59.             pageData.messageText = errorText;
  60.             return pageData;
  61.         }
  62.  
  63.         // create a new transaction
  64.         pageData.transaction = new Transaction(name,email,address,city,company,state,country,zip,phone);
  65.  
  66.         return pageData;
  67.     }
  68.    
  69.    
  70.    
  71. }