Java Reference
In-Depth Information
L ISTING 12.9
Continued
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Get all of the information from the request.
Integer months =
new Integer(request.getParameter(“months”));
Float principal =
new Float(request.getParameter(“principal”));
String custName = request.getParameter(“name”);
String phoneNumber = request.getParameter(“phone”);
Float payment = null;
Float interestRate = null;
CalculateLoanHome clHome = null;
CalculateLoan cl = null;
QuoteHome quoteHome = null;
Quote quote = null;
try
{
// Lookup the home interface for the CaluclateLoan Bean
Object obj = ctx.lookup(“CalculateLoan”);
clHome = (CalculateLoanHome)
PortableRemoteObject.narrow(obj,
Class.forName(“CalculateLoanHome”));
// Create a new remote interface
cl = clHome.create();
// Calculate the monthly payment and get the
// current interest rate.
payment = cl.calcMonthlyPayment(months, principal);
interestRate = cl.getCurrentInterestRate();
// Lookup the home interface for the Quote Bean
obj = ctx.lookup(“Quote”);
quoteHome = (QuoteHome)
PortableRemoteObject.narrow(obj,
Class.forName(“QuoteHome”));
// Insert a new Quote into the database with the id of '1'
quote = quoteHome.create(new Integer(1));
// Update the database entry with all
// of the necessary information.
Search WWH ::




Custom Search