Accessibility
 
Home > Products > UltraDev > Support > Building Common Applications
Dreamweaver UltraDev Icon Macromedia Dreamweaver UltraDev Support Center - Building Common Applications
Defining the problem

You want to separate the JSP logic and HTML presentation to meet the needs of the different teams working on the Arrow application. For example, the page designers want to work on pages uncluttered by JSP code, while the JSP developers want to prevent their code from being accidently modified by the designers.

Even on a simple page like the welcome page shown in the previous section of this article, the JSP code can quickly clutter up the HTML code. For example, here's the code that produces the list of consecutive dates in a custom, lowercase format:

<%@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);
}
%>

For more information on this code, see Arrow Aircraft 6: Working with dates in JSP.

When you run the page, the code outputs the following list (assuming it's April 20):

The rest of this article describes how to separate the date list's code from the rest of the page.

To Table of Contents Back to Previous document Forward to next document