/* ' Copyright by Erica Andrews aka CyLiKoN JeZuZ aka Li'L CJ, ' December 1999. No one is permitted to implement this servlet ' or any portion of it on their site without the express written consent ' of the author (cylikon@hotmail.com - ./IcedPinky/). ' All rights reserved. ' This servlet was hand-coded in by Erica on Dec. 28,1999 ' It creates a Yahoo-style index of all my web sites listed in my MySQL DB. ' The servlet uses the ' gweMySQLJDBC 0.9.2 driver (rather than the JDBC-ODBC bridge) ' and MySQL 3.22.9 for database connectivity. */ import java.io.*; import java.util.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import gwe.sql.*; public class Yahoo extends HttpServlet { // -- status of our database connection -true or false boolean dbConnected; public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //Get the response's PrintWriter to return text to the client. PrintWriter toClient = res.getWriter(); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='51'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); // -- starting the page -------------------------------- toClient.print("CJ's Yahoo - Java Servlet Version

CJ's Yahoo - Java Servlet Version

Local Sites - This Server
My Resume
"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // --------Handling Driver Not Found Exceptions --------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Technical Playground
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='52'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
IIS Site Maintenance (Private-Password Required)





My Sites: AOL Server
Home Page
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='1'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
NYC Site
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='2'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Lesbian-Gay
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='5'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Hiphop
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='3'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Reggae
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='4'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
My Resume
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='6'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
About Me
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='7'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Site Search
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='8'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Ghetto Haunted House
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='9'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // @@@@@@@@@@@@@@@@@@@@@@@@@@@ New Section @@@@@@@@@@@@@@@@@@@@@@@@@@@@ toClient.print("
Computers/IT
"); try { // --- grab the keyword from the query string and execute the query ----- // --- set up the driver and connect to the database ----- Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","guest","guest"); // -- get ready to execute a query - create a statement ------ Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,title,url FROM thesites WHERE itsgroup='10'"); // ----- fetch and print out the results -------- // first, set the "content type" header of the response res.setContentType("text/html"); while (rset.next ()) { String id=rset.getString(1).trim(); String itsgroup=rset.getString(2).trim(); String title=rset.getString(3).trim(); String url=rset.getString(4).trim(); toClient.print (""); toClient.print (title); toClient.print(""); toClient.print("
"); } toClient.print("
"); // -- handling miscellaneous problems with the query --------- } catch(SQLException e) { e.printStackTrace(); toClient.println( "A problem occured while processing your query. " + "Please try again."); } // -------- catch (ClassNotFoundException e) { System.err.println("JDBC-ODBC driver not found"); throw new UnavailableException (this, "Database driver not found"); } // -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // ----------------- // Close the writer; the response is done. toClient.close(); } }