import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.net.*; import java.sql.*; import java.util.*; import myDatabase; /** * ImageDBServlet.java * * This servlet demonstrates how to use JDBC driver to access the * image database from the servlet, thus shows a 3-tier JDBC example. * * @author xjqiu@npac.syr.edu */ public class ImageDBServlet extends HttpServlet { String imgname; String color; String type; String url; String noneLabel=" "; /** * doGet() method * At Server side, collection query information from client side interface, * access Image Database, send back HTML file containing query results */ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { Connection con; PrintWriter out; res.setContentType("text/html"); out = new PrintWriter(res.getOutputStream()); // Fetch the parameters from client side // while checking each field of the query table. // Perform Database Access according to the value combinations provieded from User. String cntrl = req.getParameter("control"); if(cntrl != null) { if (cntrl.equals("Search")) {//Search button pressed printPageHeader(out); printPageFooter(out); } } } private void printPageHeader(PrintWriter out) { out.println(""); out.println(""); out.println("Servlet"); out.println(""); out.println(""); out.println("

This is a test.

"); } private void printPageFooter(PrintWriter out) { out.println(""); out.println(""); out.close(); } }//end of class