00001 import javax.servlet.http.HttpServletRequest; 00002 import javax.servlet.http.HttpServletResponse; 00003 import java.io.PrintWriter; 00004 00005 public class Page 00006 { 00007 public static final String STATIC_PATH = "/"; 00008 public static final String PATH = "/"; 00009 public static final String INDEX = "Home"; 00010 00011 public HttpServletRequest req; 00012 public HttpServletResponse res; 00013 PrintWriter pw; 00014 String uri; 00015 00016 public Page(HttpServletRequest req, HttpServletResponse res, PrintWriter pw) 00017 { 00018 this.req = req; 00019 this.res = res; 00020 this.pw = pw; 00021 uri = req.getRequestURI(); 00022 } 00023 00024 public void p(String str) 00025 { 00026 pw.print(str); 00027 } 00028 00029 public void top(String s) 00030 { 00031 p( 00032 "<html>\n"+ 00033 "<head><title>" + s + "</title></head>\n"+ 00034 "<body>\n"+ 00035 "<table cellpadding=3 cellspacing=0 border=0>\n"+ 00036 "<tr>\n"+ 00037 "<td colspan=2 bgcolor=\"#003366\" align=left><font size=5 color=white>Doctor Database</font></td></td>\n"+ 00038 "</tr>\n"+ 00039 "<tr>\n"+ 00040 "<td bgcolor=\"#99ccff\" valign=top>\n"+ 00041 "" 00042 ); 00043 pageLink("Home", "Home"); 00044 pageLink("Appointments", "Appointments"); 00045 pageLink("Patients", "Patients"); 00046 pageLink("Table Editor", "Tables"); 00047 pageLink("Browsable Source", "../dox/hierarchy.html"); 00048 p( 00049 "</td>\n"+ 00050 "<td>\n"+ 00051 "" 00052 ); 00053 } 00054 00055 public void bottom() 00056 { 00057 p( 00058 "\n"+ 00059 "</td>\n"+ 00060 "</tr>\n"+ 00061 "</table>\n"+ 00062 "</body>\n"+ 00063 "</html>\n"+ 00064 "" 00065 ); 00066 } 00067 00068 public void pageLink(String caption, String link) 00069 { 00070 pageLink(caption,link,"",""); 00071 } 00072 00073 public void pageLink(String caption, String link, String extlink, String params) 00074 { 00075 int l = PATH.length() + link.length(); 00076 pageLink(caption, link + extlink, 00077 ((uri.length() < l 00078 || !uri.substring(0,l).equals(PATH + link)) 00079 && !(link.equals(INDEX) && uri.equals(PATH))), 00080 params); 00081 } 00082 00083 public void pageLink(String caption, String link, boolean islink, String params) 00084 { 00085 if (islink) 00086 pw.println("<p><a href=\"" + PATH + link + "\">" + caption + "</a></p>"); 00087 else 00088 pw.println("<p" + params + ">" + caption + "</p>"); 00089 } 00090 }