<%@ page import="java.io.*" %> <%@ page import="java.text.*" %> <%@ page import="java.util.*" %> <%@ page import="javax.xml.parsers.*" %> <%@ page import="org.w3c.dom.*" %> <%! private static final String TITLE_PREFIX = "Paul and Sarah's Crazy Road Trip Adventure - "; %> <%! private static final String FILE_DATE_FORMAT = "MMMMM dd, yyyy"; %> <%! private static final SimpleDateFormat fileDateFormatter = new SimpleDateFormat(FILE_DATE_FORMAT, Locale.US); %> <%! private static final String HEADER_DATE_FORMAT = "EEEEE, MMMMM dd, yyyy"; %> <%! private static final SimpleDateFormat headerDateFormatter = new SimpleDateFormat(HEADER_DATE_FORMAT, Locale.US); %> <%! private static final String TAB = "     "; %> <%! private static final String SECTION_SPACER = "
"; %> <%! private static final String[] SEPT_DESTINATIONS = { "cleveland", "chicago", "driving_day_1", "yellowstone", "wallowa", "portland", "west_coast" }; %> <%! private static final String[] OCT_DESTINATIONS = { "napa", "san_francisco", "la_paz", "monterey", "san_luis_obispo", "las_vegas", "grand_canyon", "flagstaff", "albuquerque", "siloam_springs", "pine_bluff", "memphis", "asheville", "home" }; %> <%! private static final String getUrl(HttpServletRequest request) { String requestURL = HttpUtils.getRequestURL(request).toString(); int idx = requestURL.lastIndexOf('/'); String urlFileNoExtension = requestURL.substring(0, idx+1); return urlFileNoExtension; } private static final Document getDestinationXML (HttpServletRequest request, String destination) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document destXMLDoc = builder.parse( getUrl(request) + destination + ".xml" ); return destXMLDoc; } private static final Date getArrivalDate (Document destXMLDoc) throws Exception { // arrival date Element docElem = destXMLDoc.getDocumentElement(); NodeList arrivalNodes = docElem.getElementsByTagName("arrival"); Node arrivalNode = arrivalNodes.item(0).getFirstChild(); String arrivalNodeValue = arrivalNode.getNodeValue(); Date arrivalDate = fileDateFormatter.parse(arrivalNodeValue); return arrivalDate; } private static final Date getDepartureDate (Document destXMLDoc) throws Exception { // departure date Element docElem = destXMLDoc.getDocumentElement(); NodeList departureNodes = docElem.getElementsByTagName("departure"); Node departureNode = departureNodes.item(0).getFirstChild(); String departureNodeValue = departureNode.getNodeValue(); Date departureDate = fileDateFormatter.parse(departureNodeValue); return departureDate; } private static final String getPreviousPage (String thisPage) { for (int i = 0; i < SEPT_DESTINATIONS.length; i++) { if (SEPT_DESTINATIONS[i].equals(thisPage)) { if (i == 0) return null; return SEPT_DESTINATIONS[i-1]; } } for (int i = 0; i < OCT_DESTINATIONS.length; i++) { if (OCT_DESTINATIONS[i].equals(thisPage)) { if (i == 0) return SEPT_DESTINATIONS[SEPT_DESTINATIONS.length-1]; return OCT_DESTINATIONS[i-1]; } } return null; } private static final String getNextPage (String thisPage) { for (int i = 0; i < SEPT_DESTINATIONS.length; i++) { if (SEPT_DESTINATIONS[i].equals(thisPage)) { if (i == SEPT_DESTINATIONS.length-1) return OCT_DESTINATIONS[0]; return SEPT_DESTINATIONS[i+1]; } } for (int i = 0; i < OCT_DESTINATIONS.length; i++) { if (OCT_DESTINATIONS[i].equals(thisPage)) { if (i == OCT_DESTINATIONS.length-1) return null; return OCT_DESTINATIONS[i+1]; } } return null; } %> <% try { %>