Java Reference
In-Depth Information
L ISTING 7.5 Continued
//Process the HTTP Get request
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Set the response content-type
response.setContentType(“text/html”);
// get the Writer object
PrintWriter out = response.getWriter();
out.println(“<html>\n<body>\n<table border=\”1\” width=\”100%\”>”);
// Get the search_string parameter, passed from the
// SearchServlet.
String search_string =
request.getParameter(“search_string”);
Connection con = null;
try {
// Load the Driver class file
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
System.err.println(“Getting Connection!”);
// Make a connection to the ODBC datasource Movie Catalog
// In this example we are opening a connection to the
// database with every request.
con = DriverManager.getConnection(“jdbc:odbc:Movie Catalog”,
“”, “”);
if ( con != null ) {
System.err.println(“Got Connection!”);
Search WWH ::




Custom Search