Java Reference
In-Depth Information
Now that you have an idea as to what the site will look like, let's add the functionality to actu-
ally make it work. Your first steps in doing this are going to be adding the necessary Service
classes that include your business logic. You will be adding three services. Each of these of
these Service classes will implement the Service interface. The following sections describe
each of these classes and where they fit into your Web application.
The GetQuote Service
The GetQuote class, like all other service classes in your server-side model, implements the
Service interface. The implemented execute() method is where all of its major functionality
exists. It starts its execution when a user selects and enters a stock symbol into the form in the
titlebar.jsp and clicks the Get Quote button. When its execution starts, it gets the stock
symbol from the request and performs a select statement on the stocks table, returning a
ResultSet containing the attributes associated with the stock with the matching symbol. The
stock attributes are then added to the request object and forwarded to the named target, which
in this case is the previously listed getquote.jsp . The source for GetQuote is found in Listing
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import java.sql.*;
import Service;
import ConnectionPool.ConnectionPool;
public class GetQuote implements Service {
public GetQuote() {
Search WWH ::

Custom Search