// ------------------------------------------------------ // index.html // // This is the "welcome" page for the job service and it // shows the the current list of jobs. // // Copyright (c) 1998. Stephen M. Bate, // Object Computing, Inc. All rights reserved. // // This software is being provided by the copyright // holder under the following license. By obtaining, using // and/or copying this software, you agree that you have // read, understood, and will comply with the following // terms and conditions: // // Permission to use, copy, modify, and distribute this // software and its documentation for any purpose and // without fee or royalty is hereby granted, provided that // the full text of this NOTICE appears on ALL copies of // the software and documentation or portions thereof, // including modifications, that you make. // // THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS // MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR // IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, // COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES // OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE // OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT // INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS // OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL BEAR NO // LIABILITY FOR ANY USE OF THIS SOFTWARE OR DOCUMENTATION. // // Title to copyright in this software and any associated // documentation will at all times remain with copyright // holder. Phoenix Java User's Group - Job Listings // Note: import,extends, etc. don't have to be // at the top of the jhtml file. // ------------------------------------------------------ // ** Import declarations ** // Note: Don't put 'import' at the beginning of each line // Also, the ';' at the end of the line doesn't appear to // hurt, but it's not necessary. // // Note: To place extended comments in a jhtml file without // increasing the HTML file size (and lengthening download // times), place the comments in a java tag. Neither java // comments or HTML comments may be placed inside of certain // types of java tags (e.g., import, extends). java.sql.* java.text.SimpleDateFormat // ------------------------------------------------------ // ** Extends declaration ** // We are inheriting several functionality like pooled // database connections from the base class org.phxjug.db.DatabaseServlet // ------------------------------------------------------ // Create a shared formatter to be used by all threads. // The formatter variable is a class variable instead of // a variable local to the service() method. // SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yy");


Phoenix Java Job Opportunities

[Maintain Jobs] [How to Submit]

// ------------------------------------------------------ // Start the table. The table is generated with static // html to specify the table attributes and headings. // Then java code is wrapped around the row generation // to create a row for each result from a JDBC query. // This java code preceedes the row generation. There is a // chunk of code before the loop (this chunk) and a // chunk of code after the loop. See the while loop that // starts before the code generate in the java tag and // ends in the java tag after the row generation. // Declare connection, statement, and result set variables // which will be used to access the database using JDBC. // These variables are declared outside the try block so // they will be available in the catch block if an error // occurs. Connection con = null; Statement stmt = null; ResultSet result = null; try { // Get the connection - this accesses the connection pool // defined in the base class. Create the statement using // the connection. con = getConnection(); stmt = con.createStatement(); // Execute the SQL query to retrieve all 'active' jobs. // The active flag is used to 'delete' jobs. By using this // flag, the client doesn't require delete priviledges // for the database since only an update (of the active // flag is required. String query = "select * from job where active = 'Y'"; result = stmt.executeQuery(query); // Retrieve the rows and extract the data we will display. // The data could be retrieved directed in subsequent // JAVA tags, but I find this approach results in simpler // syntax during row generation (see below). while(result.next()) { // Retrieve column information using the column name int id = result.getInt("id"); String abs = result.getString("abstract"); // Format the date using the SimpleDateFormatter. // It might be better to move the formatter into the // base class and put the format string in the db // properties file. That way, the date format can // changed in one place and it will be reflected // in all the jhtml files with use DatabaseServlet // as the base class. String date = formatter.format(result.getTimestamp("timetag")); // Generate a row of data. The java print tag is used to // simplify the reference to column variables. I put the // row-related comments in the java tag so the row comments // would not be output to the client (thus slowing down // the data transfer). Notice the use of backticks in the // the abstract's hyperlink (`id`). Remember, this method // of printing the value of an expression only works in // html tags (maybe only anchors?). It won't work in // HTML content. // // This is the trailing Java code which wraps the row generation. // Notice the while block started before the row generation and // ends after this comment. } // end of while loop } // end of try block surrounding query // // Handle any exceptions that occurred during the row // generation. // catch (Exception e) { // Log the exception to the servlet log file and // include a stack trace. getServletContext().log(e, "query failed"); } finally { try { // Close the statement and result set, // if they were created before the exception occurred. if (stmt != null) stmt.close(); if (result != null) result.close(); } // Even the cleanup can cause an exception! catch (Exception e) { getServletContext().log(e, "query cleanup failed"); } // Return the connection to the pool, so the next request // can use it (implemented in the base class). freeConnection(con); }
Date Short Description
date abs
// ------------------------------------------------------ // Include the common footer. The footer is placed in the // /_private/jws_footer.html file and can be included // from any jhtml pages on the web site.