<%@ page import="java.util.*, java.sql.*, java.text.*, journal.*;" %> Tim Gades' Homepage: Journal

Journal

<% List entries; DatabaseConnection cxn; int i, commentCount, editCount; Entry entry; SimpleDateFormat sdf = new SimpleDateFormat("EEEE, dd MMMM yyyy @ HH:mm"); SimpleDateFormat editDateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); String dateString; cxn = new DatabaseConnection(getServletConfig().getServletContext().getRealPath("config.path")); cxn.open(); if(cxn.isOpen()) { entries = cxn.getLastNEntries(5); for(i = 0; i < entries.size(); i++) { entry = (Entry)entries.get(i); dateString = sdf.format(entry.getTimestamp()); %>
<%= dateString %> <%= entry.getTitle() %>
<%= entry.getBody() %>
<% // COMMENTS commentCount = cxn.getNumCommentsForEntry(entry.getId()); if(commentCount > 0) { %> <%= commentCount %> <% if(commentCount > 1) { %>comments<% } else { %>comment<% } %> | <% } %> add comment  <% // EDIT INFORMATION editCount = entry.getEditCount(); if(editCount > 0) { // get last edit date dateString = editDateFormat.format(entry.getLastEditTimestamp()); out.println("Last edited " + dateString + ", "); if(editCount > 1) out.println("edited " + editCount + " times in total."); else out.println("edited 1 time in total."); } %>
<% } cxn.close(); } else { %> Could not get journal entries or journal empty. <% } %>

- Previous Entries -