Separating the Arrow logic
In the Arrow Aircraft welcome page, you separate the date-list logic from the rest of the page by creating a new document (File > New) and naming it datelist.jsp. Next, you move all the date-list logic from the welcome page to the datelist.jsp page. When you're done, the contents of the datelist.jsp page consists of the following:
<%@page import="java.util.GregorianCalendar"%>
<%
//Create custom name arrays for months and weekdays
String[] monthNames = {"january","february","march","april","may","june",
"july","august","september","october","november","december"};
String[] dayNames = {"sunday","monday","tuesday","wednesday","thursday",
"friday","saturday"};
//Create dateInfo object containing current date
GregorianCalendar dateInfo = new GregorianCalendar();
//Output list of dates starting with current date
for (int i = 0; i < 14; i++) {
String day = dayNames[dateInfo.get(dateInfo.DAY_OF_WEEK) - 1];
String month = monthNames[dateInfo.get(dateInfo.MONTH)];
int date = dateInfo.get(dateInfo.DATE);
out.print(day + ", " + month + " " + date + "<br>");
dateInfo.roll(dateInfo.DAY_OF_YEAR, true);
}
%>
Back on the welcome page, you add a single line to generate the list of consecutive dates:
<jsp:include page="datelist.jsp" flush="true"/>
Try it out. First, make sure you have a working JSP site in UltraDev, then do the following.
1 |
Create a new JSP page. |
2 |
Switch to Code view (View > Code) and type the following tag somewhere in the HTML body code:
<jsp:include page="datelist.jsp" flush="true"/>
|
3 |
Download the following tag file and place it with your other JSP files on the server along with the JSP document you just created. |
|
Download the Windows datelist.jsp file datelist.zip (120K)
Download the Macintosh datelist.jsp file datelist.sea.hqx (292K) |
4 |
Open your browser and run the JSP page you created. |
|
|
The <jsp:include> tag will generate a list of 14 dates starting with the current date.
|