Extend checks to webapps
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 24 Jul 2010 12:23:44 +0000 (12:23 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 24 Jul 2010 12:23:44 +0000 (12:23 +0000)
Tab police for /test and /webapps

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@978861 13f79535-47bb-0310-9956-ffa450edef68

28 files changed:
build.xml
test/org/apache/catalina/loader/TestWebappClassLoaderMemoryLeak.java
test/org/apache/catalina/mbeans/TestRegistration.java
test/org/apache/catalina/tribes/test/interceptors/TestOrderInterceptor.java
test/org/apache/catalina/tribes/test/membership/TestMemberSerialization.java
webapps/docs/appdev/sample/src/mypackage/Hello.java
webapps/examples/WEB-INF/classes/CookieExample.java
webapps/examples/WEB-INF/classes/HelloWorldExample.java
webapps/examples/WEB-INF/classes/RequestHeaderExample.java
webapps/examples/WEB-INF/classes/RequestInfoExample.java
webapps/examples/WEB-INF/classes/RequestParamExample.java
webapps/examples/WEB-INF/classes/cal/Entries.java
webapps/examples/WEB-INF/classes/cal/JspCalendar.java
webapps/examples/WEB-INF/classes/cal/TableBean.java
webapps/examples/WEB-INF/classes/checkbox/CheckTest.java
webapps/examples/WEB-INF/classes/dates/JspCalendar.java
webapps/examples/WEB-INF/classes/error/Smart.java
webapps/examples/WEB-INF/classes/examples/FooTag.java
webapps/examples/WEB-INF/classes/examples/ShowSource.java
webapps/examples/WEB-INF/classes/jsp2/examples/el/Functions.java
webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/EchoAttributesTag.java
webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/FindBookSimpleTag.java
webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/HelloWorldSimpleTag.java
webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/RepeatSimpleTag.java
webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/TileSimpleTag.java
webapps/examples/WEB-INF/classes/listeners/ContextListener.java
webapps/examples/WEB-INF/classes/listeners/SessionListener.java
webapps/examples/WEB-INF/classes/servletToJsp.java

index c50268b..fb8909d 100644 (file)
--- a/build.xml
+++ b/build.xml
       <fileset dir="test">
         <include name="**/*.java" />
       </fileset>
+      <fileset dir="webapps">
+        <include name="**/*.java" />
+      </fileset>
        </checkstyle>
   </target>
 
index 526e22d..f232591 100644 (file)
@@ -56,9 +56,9 @@ public class TestWebappClassLoaderMemoryLeak extends TomcatBaseTest {
         
         // If the thread still exists, we have a thread/memory leak
         try {
-           Thread.sleep(10);
+            Thread.sleep(10);
         } catch(InterruptedException ie) {
-           // ignore
+            // ignore
         }
         Thread[] threads = getThreads();
         for (Thread thread : threads) {
index d137061..8f4ed61 100644 (file)
@@ -39,8 +39,8 @@ public class TestRegistration extends TomcatBaseTest {
      * registered.
      * @author Marc Guillemot
      */
-       public void testMBeanDeregistration() throws Exception {
-               final MBeanServer mbeanServer = Registry.getRegistry(null, null).getMBeanServer();
+    public void testMBeanDeregistration() throws Exception {
+        final MBeanServer mbeanServer = Registry.getRegistry(null, null).getMBeanServer();
         Set<ObjectName> onames = mbeanServer.queryNames(new ObjectName("Catalina:*"), null);
         assertEquals("Remaining: " + onames, 0, onames.size());
 
@@ -88,6 +88,6 @@ public class TestRegistration extends TomcatBaseTest {
         assertEquals("Remaining: " + onames, 0, onames.size());
         onames = mbeanServer.queryNames(new ObjectName("Tomcat:*"), null);
         assertEquals("Remaining: " + onames, 0, onames.size());
-       }
-       
+    }
+    
 }
index b62e698..2d502a3 100644 (file)
@@ -119,8 +119,8 @@ public class TestOrderInterceptor extends TestCase {
             threads[i].join();
         }
         if (!exceptionQueue.isEmpty()) {
-               fail("Exception while sending in threads: " 
-                               + exceptionQueue.remove().toString());
+            fail("Exception while sending in threads: " 
+                    + exceptionQueue.remove().toString());
         }
         Thread.sleep(5000);
         for ( int i=0; i<test.length; i++ ) {
index 2eef441..2e5fd1e 100644 (file)
@@ -63,16 +63,14 @@ public class TestMemberSerialization extends TestCase {
     }
     
     public void testUdpPort() throws Exception {
-       byte[] md1 = m1.getData();
-       byte[] md2 = m2.getData();
+        byte[] md1 = m1.getData();
+        byte[] md2 = m2.getData();
 
         MemberImpl a1 = MemberImpl.getMember(md1);
         MemberImpl a2 = MemberImpl.getMember(md2);
         
         assertEquals(true, a1.getUdpPort()==a2.getUdpPort());
         assertEquals(true,a1.getUdpPort()==udpPort);
-
-       
     }
     
     public void testSerializationOne() throws Exception {
index ebc9381..ea25792 100644 (file)
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package mypackage;
 
 import java.io.IOException;
@@ -52,30 +51,30 @@ public final class Hello extends HttpServlet {
                       HttpServletResponse response)
       throws IOException, ServletException {
 
-       response.setContentType("text/html");
-       PrintWriter writer = response.getWriter();
+        response.setContentType("text/html");
+        PrintWriter writer = response.getWriter();
 
-       writer.println("<html>");
-       writer.println("<head>");
-       writer.println("<title>Sample Application Servlet Page</title>");
-       writer.println("</head>");
-       writer.println("<body bgcolor=white>");
+        writer.println("<html>");
+        writer.println("<head>");
+        writer.println("<title>Sample Application Servlet Page</title>");
+        writer.println("</head>");
+        writer.println("<body bgcolor=white>");
 
-       writer.println("<table border=\"0\">");
-       writer.println("<tr>");
-       writer.println("<td>");
-       writer.println("<img src=\"images/tomcat.gif\">");
-       writer.println("</td>");
-       writer.println("<td>");
-       writer.println("<h1>Sample Application Servlet</h1>");
-       writer.println("This is the output of a servlet that is part of");
-       writer.println("the Hello, World application.");
-       writer.println("</td>");
-       writer.println("</tr>");
-       writer.println("</table>");
+        writer.println("<table border=\"0\">");
+        writer.println("<tr>");
+        writer.println("<td>");
+        writer.println("<img src=\"images/tomcat.gif\">");
+        writer.println("</td>");
+        writer.println("<td>");
+        writer.println("<h1>Sample Application Servlet</h1>");
+        writer.println("This is the output of a servlet that is part of");
+        writer.println("the Hello, World application.");
+        writer.println("</td>");
+        writer.println("</tr>");
+        writer.println("</table>");
 
-       writer.println("</body>");
-       writer.println("</html>");
+        writer.println("</body>");
+        writer.println("</html>");
 
     }
 
index e99e9a9..3c1c58a 100644 (file)
@@ -54,12 +54,12 @@ public class CookieExample extends HttpServlet {
         out.println("</head>");
         out.println("<body>");
 
-       // relative links
+        // relative links
 
         // XXX
         // making these absolute till we work out the
         // addition of a PathInfo issue 
-       
+
         out.println("<a href=\"../cookies.html\">");
         out.println("<img src=\"../images/code.gif\" height=24 " +
                     "width=24 align=right border=0 alt=\"view code\"></a>");
index be8cb06..cc2c6b6 100644 (file)
@@ -46,22 +46,22 @@ public class HelloWorldExample extends HttpServlet {
         out.println("<html>");
         out.println("<head>");
 
-           String title = rb.getString("helloworld.title");
+        String title = rb.getString("helloworld.title");
 
-           out.println("<title>" + title + "</title>");
+        out.println("<title>" + title + "</title>");
         out.println("</head>");
         out.println("<body bgcolor=\"white\">");
 
-       // note that all links are created to be relative. this
-       // ensures that we can move the web application that this
-       // servlet belongs to to a different place in the url
-       // tree and not have any harmful side effects.
+        // note that all links are created to be relative. this
+        // ensures that we can move the web application that this
+        // servlet belongs to to a different place in the url
+        // tree and not have any harmful side effects.
 
         // XXX
         // making these absolute till we work out the
         // addition of a PathInfo issue
 
-           out.println("<a href=\"../helloworld.html\">");
+        out.println("<a href=\"../helloworld.html\">");
         out.println("<img src=\"../images/code.gif\" height=24 " +
                     "width=24 align=right border=0 alt=\"view code\"></a>");
         out.println("<a href=\"../index.html\">");
index 3d0be7c..1dd7bac 100644 (file)
@@ -54,12 +54,12 @@ public class RequestHeaderExample extends HttpServlet {
         out.println("</head>");
         out.println("<body>");
 
-       // all links relative
+        // all links relative
 
         // XXX
         // making these absolute till we work out the
         // addition of a PathInfo issue 
-       
+
         out.println("<a href=\"../reqheaders.html\">");
         out.println("<img src=\"../images/code.gif\" height=24 " +
                     "width=24 align=right border=0 alt=\"view code\"></a>");
index 256a5ed..d9ad44a 100644 (file)
@@ -55,12 +55,12 @@ public class RequestInfoExample extends HttpServlet {
         out.println("<body bgcolor=\"white\">");
 
         // img stuff not req'd for source code html showing
-       // all links relative!
+        // all links relative!
 
         // XXX
         // making these absolute till we work out the
         // addition of a PathInfo issue
-       
+
         out.println("<a href=\"../reqinfo.html\">");
         out.println("<img src=\"../images/code.gif\" height=24 " +
                     "width=24 align=right border=0 alt=\"view code\"></a>");
@@ -88,21 +88,20 @@ public class RequestInfoExample extends HttpServlet {
         out.println("</td></tr><tr><td>");
         out.println(RB.getString("requestinfo.label.remoteaddr"));
 
-       String cipherSuite=
-           (String)request.getAttribute("javax.servlet.request.cipher_suite");
+        String cipherSuite=
+            (String)request.getAttribute("javax.servlet.request.cipher_suite");
         out.println("</td><td>");                
         out.println(request.getRemoteAddr());
         out.println("</table>");
-
-       if(cipherSuite!=null){
-           out.println("</td></tr><tr><td>");  
-           out.println("SSLCipherSuite:");
-           out.println("</td>");
-           out.println("<td>");            
-           out.println(request.getAttribute("javax.servlet.request.cipher_suite"));
-           out.println("</td>");           
-       }
-       
+        
+        if(cipherSuite!=null){
+            out.println("</td></tr><tr><td>");
+            out.println("SSLCipherSuite:");
+            out.println("</td>");
+            out.println("<td>");    
+            out.println(request.getAttribute("javax.servlet.request.cipher_suite"));
+            out.println("</td>");
+        }
     }
 
     @Override
index 984de8e..9a7ab42 100644 (file)
@@ -56,12 +56,12 @@ public class RequestParamExample extends HttpServlet {
 
         // img stuff not req'd for source code html showing
 
-       // all links relative
+       // all links relative
 
         // XXX
         // making these absolute till we work out the
         // addition of a PathInfo issue 
-       
+
         out.println("<a href=\"../reqparams.html\">");
         out.println("<img src=\"../images/code.gif\" height=24 " +
                     "width=24 align=right border=0 alt=\"view code\"></a>");
index 9b5d587..03afc7e 100644 (file)
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package cal;
 
 import java.util.Hashtable;
@@ -21,52 +21,39 @@ import javax.servlet.http.*;
 
 public class Entries {
 
-  private Hashtable<String, Entry> entries;
-  private static final String[] time = {"8am", "9am", "10am", "11am", "12pm", 
-                                       "1pm", "2pm", "3pm", "4pm", "5pm", "6pm",
-                                       "7pm", "8pm" };
-  public static final int rows = 12;
+    private Hashtable<String, Entry> entries;
+    private static final String[] time = { "8am", "9am", "10am", "11am",
+            "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", "7pm", "8pm" };
+    public static final int rows = 12;
 
-  public Entries () {   
-   entries = new Hashtable<String, Entry> (rows);
-   for (int i=0; i < rows; i++) {
-     entries.put (time[i], new Entry(time[i]));
-   }
-  }
+    public Entries() {
+        entries = new Hashtable<String, Entry>(rows);
+        for (int i = 0; i < rows; i++) {
+            entries.put(time[i], new Entry(time[i]));
+        }
+    }
 
-  public int getRows () {
-    return rows;
-  }
+    public int getRows() {
+        return rows;
+    }
 
-  public Entry getEntry (int index) {
-    return this.entries.get(time[index]);
-  }
+    public Entry getEntry(int index) {
+        return this.entries.get(time[index]);
+    }
 
-  public int getIndex (String tm) {
-    for (int i=0; i<rows; i++)
-      if(tm.equals(time[i])) return i;
-    return -1;
-  }
+    public int getIndex(String tm) {
+        for (int i = 0; i < rows; i++)
+            if (tm.equals(time[i]))
+                return i;
+        return -1;
+    }
 
-  public void processRequest (HttpServletRequest request, String tm) {
-    int index = getIndex (tm);
-    if (index >= 0) {
-      String descr = request.getParameter ("description");
-      entries.get(time[index]).setDescription (descr);
+    public void processRequest(HttpServletRequest request, String tm) {
+        int index = getIndex(tm);
+        if (index >= 0) {
+            String descr = request.getParameter("description");
+            entries.get(time[index]).setDescription(descr);
+        }
     }
-  }
 
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
index a15242c..34d1c5b 100644 (file)
@@ -23,127 +23,127 @@ public class JspCalendar {
     Calendar  calendar = null;
 
     public JspCalendar() {
-       calendar = Calendar.getInstance();
-       Date trialTime = new Date();
-       calendar.setTime(trialTime);
+        calendar = Calendar.getInstance();
+        Date trialTime = new Date();
+        calendar.setTime(trialTime);
     }
 
 
     public int getYear() {
-       return calendar.get(Calendar.YEAR);
+        return calendar.get(Calendar.YEAR);
     }
     
     public String getMonth() {
-       int m = getMonthInt();
-       String[] months = new String [] { "January", "February", "March",
-                                       "April", "May", "June",
-                                       "July", "August", "September",
-                                       "October", "November", "December" };
-       if (m > 12)
-           return "Unknown to Man";
-       
-       return months[m - 1];
+        int m = getMonthInt();
+        String[] months = new String [] { "January", "February", "March",
+                                        "April", "May", "June",
+                                        "July", "August", "September",
+                                        "October", "November", "December" };
+        if (m > 12)
+            return "Unknown to Man";
+        
+        return months[m - 1];
 
     }
 
     public String getDay() {
-       int x = getDayOfWeek();
-       String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", 
-                                     "Thursday", "Friday", "Saturday"};
+        int x = getDayOfWeek();
+        String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", 
+                                      "Thursday", "Friday", "Saturday"};
 
-       if (x > 7)
-           return "Unknown to Man";
+        if (x > 7)
+            return "Unknown to Man";
 
-       return days[x - 1];
+        return days[x - 1];
 
     }
     
     public int getMonthInt() {
-       return 1 + calendar.get(Calendar.MONTH);
+        return 1 + calendar.get(Calendar.MONTH);
     }
 
     public String getDate() {
-       return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();        
+        return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();
     }
 
     public String getCurrentDate() {
         Date dt = new Date ();
-       calendar.setTime (dt);
-       return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();
+        calendar.setTime (dt);
+        return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();
 
     }
 
     public String getNextDate() {
         calendar.set (Calendar.DAY_OF_MONTH, getDayOfMonth() + 1);
-       return getDate ();
+        return getDate ();
     }
 
     public String getPrevDate() {
         calendar.set (Calendar.DAY_OF_MONTH, getDayOfMonth() - 1);
-       return getDate ();
+        return getDate ();
     }
 
     public String getTime() {
-       return getHour() + ":" + getMinute() + ":" + getSecond();
+        return getHour() + ":" + getMinute() + ":" + getSecond();
     }
 
     public int getDayOfMonth() {
-       return calendar.get(Calendar.DAY_OF_MONTH);
+        return calendar.get(Calendar.DAY_OF_MONTH);
     }
 
     public int getDayOfYear() {
-       return calendar.get(Calendar.DAY_OF_YEAR);
+        return calendar.get(Calendar.DAY_OF_YEAR);
     }
 
     public int getWeekOfYear() {
-       return calendar.get(Calendar.WEEK_OF_YEAR);
+        return calendar.get(Calendar.WEEK_OF_YEAR);
     }
 
     public int getWeekOfMonth() {
-       return calendar.get(Calendar.WEEK_OF_MONTH);
+        return calendar.get(Calendar.WEEK_OF_MONTH);
     }
 
     public int getDayOfWeek() {
-       return calendar.get(Calendar.DAY_OF_WEEK);
+        return calendar.get(Calendar.DAY_OF_WEEK);
     }
      
     public int getHour() {
-       return calendar.get(Calendar.HOUR_OF_DAY);
+        return calendar.get(Calendar.HOUR_OF_DAY);
     }
     
     public int getMinute() {
-       return calendar.get(Calendar.MINUTE);
+        return calendar.get(Calendar.MINUTE);
     }
 
 
     public int getSecond() {
-       return calendar.get(Calendar.SECOND);
+        return calendar.get(Calendar.SECOND);
     }
 
   
     public int getEra() {
-       return calendar.get(Calendar.ERA);
+        return calendar.get(Calendar.ERA);
     }
 
     public String getUSTimeZone() {
-       String[] zones = new String[] {"Hawaii", "Alaskan", "Pacific",
-                                      "Mountain", "Central", "Eastern"};
-       
-       return zones[10 + getZoneOffset()];
+        String[] zones = new String[] {"Hawaii", "Alaskan", "Pacific",
+                                       "Mountain", "Central", "Eastern"};
+        
+        return zones[10 + getZoneOffset()];
     }
 
     public int getZoneOffset() {
-       return calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
+        return calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
     }
 
 
     public int getDSTOffset() {
-       return calendar.get(Calendar.DST_OFFSET)/(60*60*1000);
+        return calendar.get(Calendar.DST_OFFSET)/(60*60*1000);
     }
 
     
     public int getAMPM() {
-       return calendar.get(Calendar.AM_PM);
+        return calendar.get(Calendar.AM_PM);
     }
 }
 
index cddd92e..d158a66 100644 (file)
@@ -1,19 +1,19 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package cal;
 
 import javax.servlet.http.*;
@@ -21,80 +21,80 @@ import java.util.Hashtable;
 
 public class TableBean {
 
-  Hashtable<String, Entries> table;
-  JspCalendar JspCal;
-  Entries entries;
-  String date;
-  String name = null;
-  String email = null;
-  boolean processError = false;
-
-  public TableBean () {
-    this.table = new Hashtable<String, Entries> (10);
-    this.JspCal = new JspCalendar ();
-    this.date = JspCal.getCurrentDate ();
-  }
-
-  public void setName (String nm) {
-    this.name = nm;
-  }
-
-  public String getName () {
-    return this.name;
-  }
-  
-  public void setEmail (String mail) {
-    this.email = mail;
-  }
-
-  public String getEmail () {
-    return this.email;
-  }
-
-  public String getDate () {
-    return this.date;
-  }
-
-  public Entries getEntries () {
-    return this.entries;
-  }
-
-  public void processRequest (HttpServletRequest request) {
-
-    // Get the name and e-mail.
-    this.processError = false;
-    if (name == null || name.equals("")) setName(request.getParameter ("name"));  
-    if (email == null || email.equals("")) setEmail(request.getParameter ("email"));
-    if (name == null || email == null ||
-               name.equals("") || email.equals("")) {
-      this.processError = true;
-      return;
+    Hashtable<String, Entries> table;
+    JspCalendar JspCal;
+    Entries entries;
+    String date;
+    String name = null;
+    String email = null;
+    boolean processError = false;
+
+    public TableBean() {
+        this.table = new Hashtable<String, Entries>(10);
+        this.JspCal = new JspCalendar();
+        this.date = JspCal.getCurrentDate();
     }
 
-    // Get the date.
-    String dateR = request.getParameter ("date");
-    if (dateR == null) date = JspCal.getCurrentDate ();
-    else if (dateR.equalsIgnoreCase("next")) date = JspCal.getNextDate ();
-    else if (dateR.equalsIgnoreCase("prev")) date = JspCal.getPrevDate ();
-
-    entries = table.get (date);
-    if (entries == null) {
-      entries = new Entries ();
-      table.put (date, entries);
+    public void setName(String nm) {
+        this.name = nm;
     }
 
-    // If time is provided add the event.
-       String time = request.getParameter("time");
-    if (time != null) entries.processRequest (request, time);
-  }
-
-  public boolean getProcessError () {
-    return this.processError;
-  }
-}
+    public String getName() {
+        return this.name;
+    }
 
+    public void setEmail(String mail) {
+        this.email = mail;
+    }
 
+    public String getEmail() {
+        return this.email;
+    }
 
+    public String getDate() {
+        return this.date;
+    }
 
+    public Entries getEntries() {
+        return this.entries;
+    }
 
+    public void processRequest(HttpServletRequest request) {
+
+        // Get the name and e-mail.
+        this.processError = false;
+        if (name == null || name.equals(""))
+            setName(request.getParameter("name"));
+        if (email == null || email.equals(""))
+            setEmail(request.getParameter("email"));
+        if (name == null || email == null || name.equals("")
+                || email.equals("")) {
+            this.processError = true;
+            return;
+        }
+
+        // Get the date.
+        String dateR = request.getParameter("date");
+        if (dateR == null)
+            date = JspCal.getCurrentDate();
+        else if (dateR.equalsIgnoreCase("next"))
+            date = JspCal.getNextDate();
+        else if (dateR.equalsIgnoreCase("prev"))
+            date = JspCal.getPrevDate();
+
+        entries = table.get(date);
+        if (entries == null) {
+            entries = new Entries();
+            table.put(date, entries);
+        }
+
+        // If time is provided add the event.
+        String time = request.getParameter("time");
+        if (time != null)
+            entries.processRequest(request, time);
+    }
 
+    public boolean getProcessError() {
+        return this.processError;
+    }
+}
index 7307021..e38269c 100644 (file)
@@ -22,10 +22,10 @@ public class CheckTest {
     String b[] = new String[] { "1", "2", "3", "4" };
 
     public String[] getFruit() {
-       return b;
+        return b;
     }
 
     public void setFruit(String [] b) {
-       this.b = b;
+        this.b = b;
     }
 }
index 82fadd4..0008ca1 100644 (file)
@@ -22,131 +22,131 @@ public class JspCalendar {
     Calendar  calendar = null;
 
     public JspCalendar() {
-       calendar = Calendar.getInstance();
-       Date trialTime = new Date();
-       calendar.setTime(trialTime);
+        calendar = Calendar.getInstance();
+        Date trialTime = new Date();
+        calendar.setTime(trialTime);
     }
 
     public int getYear() {
-       return calendar.get(Calendar.YEAR);
+        return calendar.get(Calendar.YEAR);
     }
     
     public String getMonth() {
-       int m = getMonthInt();
-       String[] months = new String [] { "January", "February", "March",
-                                       "April", "May", "June",
-                                       "July", "August", "September",
-                                       "October", "November", "December" };
-       if (m > 12)
-           return "Unknown to Man";
-       
-       return months[m - 1];
+        int m = getMonthInt();
+        String[] months = new String [] { "January", "February", "March",
+                                        "April", "May", "June",
+                                        "July", "August", "September",
+                                        "October", "November", "December" };
+        if (m > 12)
+            return "Unknown to Man";
+        
+        return months[m - 1];
 
     }
 
     public String getDay() {
-       int x = getDayOfWeek();
-       String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", 
-                                     "Thursday", "Friday", "Saturday"};
+        int x = getDayOfWeek();
+        String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", 
+                                      "Thursday", "Friday", "Saturday"};
 
-       if (x > 7)
-           return "Unknown to Man";
+        if (x > 7)
+            return "Unknown to Man";
 
-       return days[x - 1];
+        return days[x - 1];
 
     }
     
     public int getMonthInt() {
-       return 1 + calendar.get(Calendar.MONTH);
+        return 1 + calendar.get(Calendar.MONTH);
     }
 
     public String getDate() {
-       return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();
+        return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();
 
     }
 
     public String getTime() {
-       return getHour() + ":" + getMinute() + ":" + getSecond();
+        return getHour() + ":" + getMinute() + ":" + getSecond();
     }
 
     public int getDayOfMonth() {
-       return calendar.get(Calendar.DAY_OF_MONTH);
+        return calendar.get(Calendar.DAY_OF_MONTH);
     }
 
     public int getDayOfYear() {
-       return calendar.get(Calendar.DAY_OF_YEAR);
+        return calendar.get(Calendar.DAY_OF_YEAR);
     }
 
     public int getWeekOfYear() {
-       return calendar.get(Calendar.WEEK_OF_YEAR);
+        return calendar.get(Calendar.WEEK_OF_YEAR);
     }
 
     public int getWeekOfMonth() {
-       return calendar.get(Calendar.WEEK_OF_MONTH);
+        return calendar.get(Calendar.WEEK_OF_MONTH);
     }
 
     public int getDayOfWeek() {
-       return calendar.get(Calendar.DAY_OF_WEEK);
+        return calendar.get(Calendar.DAY_OF_WEEK);
     }
      
     public int getHour() {
-       return calendar.get(Calendar.HOUR_OF_DAY);
+        return calendar.get(Calendar.HOUR_OF_DAY);
     }
     
     public int getMinute() {
-       return calendar.get(Calendar.MINUTE);
+        return calendar.get(Calendar.MINUTE);
     }
 
 
     public int getSecond() {
-       return calendar.get(Calendar.SECOND);
+        return calendar.get(Calendar.SECOND);
     }
 
     public static void main(String args[]) {
-       JspCalendar db = new JspCalendar();
-       p("date: " + db.getDayOfMonth());
-       p("year: " + db.getYear());
-       p("month: " + db.getMonth());
-       p("time: " + db.getTime());
-       p("date: " + db.getDate());
-       p("Day: " + db.getDay());
-       p("DayOfYear: " + db.getDayOfYear());
-       p("WeekOfYear: " + db.getWeekOfYear());
-       p("era: " + db.getEra());
-       p("ampm: " + db.getAMPM());
-       p("DST: " + db.getDSTOffset());
-       p("ZONE Offset: " + db.getZoneOffset());
-       p("TIMEZONE: " + db.getUSTimeZone());
+        JspCalendar db = new JspCalendar();
+        p("date: " + db.getDayOfMonth());
+        p("year: " + db.getYear());
+        p("month: " + db.getMonth());
+        p("time: " + db.getTime());
+        p("date: " + db.getDate());
+        p("Day: " + db.getDay());
+        p("DayOfYear: " + db.getDayOfYear());
+        p("WeekOfYear: " + db.getWeekOfYear());
+        p("era: " + db.getEra());
+        p("ampm: " + db.getAMPM());
+        p("DST: " + db.getDSTOffset());
+        p("ZONE Offset: " + db.getZoneOffset());
+        p("TIMEZONE: " + db.getUSTimeZone());
     }
 
     private static void p(String x) {
-       System.out.println(x);
+        System.out.println(x);
     }
 
 
     public int getEra() {
-       return calendar.get(Calendar.ERA);
+        return calendar.get(Calendar.ERA);
     }
 
     public String getUSTimeZone() {
-       String[] zones = new String[] {"Hawaii", "Alaskan", "Pacific",
-                                      "Mountain", "Central", "Eastern"};
-       
-       return zones[10 + getZoneOffset()];
+        String[] zones = new String[] {"Hawaii", "Alaskan", "Pacific",
+                                       "Mountain", "Central", "Eastern"};
+        
+        return zones[10 + getZoneOffset()];
     }
 
     public int getZoneOffset() {
-       return calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
+        return calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
     }
 
 
     public int getDSTOffset() {
-       return calendar.get(Calendar.DST_OFFSET)/(60*60*1000);
+        return calendar.get(Calendar.DST_OFFSET)/(60*60*1000);
     }
 
     
     public int getAMPM() {
-       return calendar.get(Calendar.AM_PM);
+        return calendar.get(Calendar.AM_PM);
     }
 }
 
index 94beb39..82c22f6 100644 (file)
@@ -1,32 +1,30 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package error;
 
 public class Smart {
 
-  String name = "JSP";
+    String name = "JSP";
 
-  public String getName () {
-       return name;
-  }    
+    public String getName() {
+        return name;
+    }
 
-  public void setName (String name) {
-       this.name = name;
-  }    
+    public void setName(String name) {
+        this.name = name;
+    }
 }
index fba2bc6..6f71657 100644 (file)
@@ -57,7 +57,7 @@ public class FooTag extends ExampleTagBase {
     @Override
     public int doStartTag() throws JspException {
         i = 0;
-       return EVAL_BODY_BUFFERED;
+        return EVAL_BODY_BUFFERED;
     }
 
     @Override
index dda3aa0..1c74c57 100644 (file)
@@ -38,10 +38,10 @@ public class ShowSource extends TagSupport {
 
     @Override
     public int doEndTag() throws JspException {
-       if ((jspFile.indexOf( ".." ) >= 0) ||
+        if ((jspFile.indexOf( ".." ) >= 0) ||
             (jspFile.toUpperCase(Locale.ENGLISH).indexOf("/WEB-INF/") != 0) ||
             (jspFile.toUpperCase(Locale.ENGLISH).indexOf("/META-INF/") != 0))
-           throw new JspTagException("Invalid JSP file " + jspFile);
+            throw new JspTagException("Invalid JSP file " + jspFile);
 
         InputStream in
             = pageContext.getServletContext().getResourceAsStream(jspFile);
index f3b665f..e8ccb82 100644 (file)
@@ -30,13 +30,13 @@ public class Functions {
 
     public static int numVowels( String text ) {
         String vowels = "aeiouAEIOU";
-       int result = 0;
+        int result = 0;
         for( int i = 0; i < text.length(); i++ ) {
-           if( vowels.indexOf( text.charAt( i ) ) != -1 ) {
-               result++;
-           }
-       }
-       return result;
+            if( vowels.indexOf( text.charAt( i ) ) != -1 ) {
+                result++;
+            }
+        }
+        return result;
     }
 
     public static String caps( String text ) {
index 97d9e0e..9a9e9d1 100644 (file)
@@ -37,19 +37,19 @@ public class EchoAttributesTag
 
     @Override
     public void doTag() throws JspException, IOException {
-       JspWriter out = getJspContext().getOut();
-       for( int i = 0; i < keys.size(); i++ ) {
-           String key = keys.get( i );
-           Object value = values.get( i );
-           out.println( "<li>" + key + " = " + value + "</li>" );
+        JspWriter out = getJspContext().getOut();
+        for( int i = 0; i < keys.size(); i++ ) {
+            String key = keys.get( i );
+            Object value = values.get( i );
+            out.println( "<li>" + key + " = " + value + "</li>" );
         }
     }
 
     public void setDynamicAttribute( String uri, String localName, 
-       Object value ) 
-       throws JspException
+        Object value ) 
+        throws JspException
     {
-       keys.add( localName );
-       values.add( value );
+        keys.add( localName );
+        values.add( value );
     }
 }
index 9cccdac..c607f1c 100644 (file)
@@ -40,6 +40,6 @@ public class FindBookSimpleTag extends SimpleTagSupport {
     }
 
     public void setVar( String var ) {
-       this.var = var;
+        this.var = var;
     }
 }
index 38a6cd3..b63ef61 100644 (file)
@@ -28,6 +28,6 @@ import java.io.IOException;
 public class HelloWorldSimpleTag extends SimpleTagSupport {
     @Override
     public void doTag() throws JspException, IOException {
-       getJspContext().getOut().write( "Hello, world!" );
+        getJspContext().getOut().write( "Hello, world!" );
     }
 }
index 5d4c5b1..38633d9 100644 (file)
@@ -33,11 +33,11 @@ public class RepeatSimpleTag extends SimpleTagSupport {
     public void doTag() throws JspException, IOException {
         for (int i=0; i<num; i++) {
             getJspContext().setAttribute("count", String.valueOf( i + 1 ) );
-           getJspBody().invoke(null);
+            getJspBody().invoke(null);
         }
     }
 
     public void setNum(int num) {
-       this.num = num;
+        this.num = num;
     }
 }
index 3737611..3a124fa 100644 (file)
@@ -31,9 +31,9 @@ public class TileSimpleTag extends SimpleTagSupport {
 
     @Override
     public void doTag() throws JspException, IOException {
-       getJspContext().getOut().write( 
-           "<td width=\"32\" height=\"32\" bgcolor=\"" + this.color + 
-           "\"><font color=\"#ffffff\"><center>" + this.label + 
+        getJspContext().getOut().write( 
+                "<td width=\"32\" height=\"32\" bgcolor=\"" + this.color + 
+                "\"><font color=\"#ffffff\"><center>" + this.label + 
                 "</center></font></td>" );
     }
 
index 3706282..8152b5f 100644 (file)
@@ -14,7 +14,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-
 package listeners;
 
 
@@ -58,8 +57,8 @@ public final class ContextListener
      */
     public void attributeAdded(ServletContextAttributeEvent event) {
 
-       log("attributeAdded('" + event.getName() + "', '" +
-           event.getValue() + "')");
+        log("attributeAdded('" + event.getName() + "', '" +
+                event.getValue() + "')");
 
     }
 
@@ -71,8 +70,8 @@ public final class ContextListener
      */
     public void attributeRemoved(ServletContextAttributeEvent event) {
 
-       log("attributeRemoved('" + event.getName() + "', '" +
-           event.getValue() + "')");
+        log("attributeRemoved('" + event.getName() + "', '" +
+                event.getValue() + "')");
 
     }
 
@@ -84,8 +83,8 @@ public final class ContextListener
      */
     public void attributeReplaced(ServletContextAttributeEvent event) {
 
-       log("attributeReplaced('" + event.getName() + "', '" +
-           event.getValue() + "')");
+        log("attributeReplaced('" + event.getName() + "', '" +
+                event.getValue() + "')");
 
     }
 
@@ -97,8 +96,8 @@ public final class ContextListener
      */
     public void contextDestroyed(ServletContextEvent event) {
 
-       log("contextDestroyed()");
-       this.context = null;
+        log("contextDestroyed()");
+        this.context = null;
 
     }
 
@@ -110,8 +109,8 @@ public final class ContextListener
      */
     public void contextInitialized(ServletContextEvent event) {
 
-       this.context = event.getServletContext();
-       log("contextInitialized()");
+        this.context = event.getServletContext();
+        log("contextInitialized()");
 
     }
 
@@ -126,10 +125,10 @@ public final class ContextListener
      */
     private void log(String message) {
 
-       if (context != null)
-           context.log("ContextListener: " + message);
-       else
-           System.out.println("ContextListener: " + message);
+        if (context != null)
+            context.log("ContextListener: " + message);
+        else
+            System.out.println("ContextListener: " + message);
 
     }
 
index 82e003c..084b08f 100644 (file)
@@ -1,23 +1,21 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package listeners;
 
-
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
@@ -26,137 +24,131 @@ import javax.servlet.http.HttpSessionBindingEvent;
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
 
-
 /**
  * Example listener for context-related application events, which were
- * introduced in the 2.3 version of the Servlet API.  This listener
- * merely documents the occurrence of such events in the application log
- * associated with our servlet context.
- *
+ * introduced in the 2.3 version of the Servlet API. This listener merely
+ * documents the occurrence of such events in the application log associated
+ * with our servlet context.
+ * 
  * @author Craig R. McClanahan
  * @version $Id$
  */
 
-public final class SessionListener
-    implements ServletContextListener,
-              HttpSessionAttributeListener, HttpSessionListener {
-
+public final class SessionListener implements ServletContextListener,
+        HttpSessionAttributeListener, HttpSessionListener {
 
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * The servlet context with which we are associated.
      */
     private ServletContext context = null;
 
-
     // --------------------------------------------------------- Public Methods
 
-
     /**
      * Record the fact that a servlet context attribute was added.
-     *
-     * @param event The session attribute event
+     * 
+     * @param event
+     *            The session attribute event
      */
     public void attributeAdded(HttpSessionBindingEvent event) {
 
-       log("attributeAdded('" + event.getSession().getId() + "', '" +
-           event.getName() + "', '" + event.getValue() + "')");
+        log("attributeAdded('" + event.getSession().getId() + "', '"
+                + event.getName() + "', '" + event.getValue() + "')");
 
     }
 
-
     /**
      * Record the fact that a servlet context attribute was removed.
-     *
-     * @param event The session attribute event
+     * 
+     * @param event
+     *            The session attribute event
      */
     public void attributeRemoved(HttpSessionBindingEvent event) {
 
-       log("attributeRemoved('" + event.getSession().getId() + "', '" +
-           event.getName() + "', '" + event.getValue() + "')");
+        log("attributeRemoved('" + event.getSession().getId() + "', '"
+                + event.getName() + "', '" + event.getValue() + "')");
 
     }
 
-
     /**
      * Record the fact that a servlet context attribute was replaced.
-     *
-     * @param event The session attribute event
+     * 
+     * @param event
+     *            The session attribute event
      */
     public void attributeReplaced(HttpSessionBindingEvent event) {
 
-       log("attributeReplaced('" + event.getSession().getId() + "', '" +
-           event.getName() + "', '" + event.getValue() + "')");
+        log("attributeReplaced('" + event.getSession().getId() + "', '"
+                + event.getName() + "', '" + event.getValue() + "')");
 
     }
 
-
     /**
      * Record the fact that this web application has been destroyed.
-     *
-     * @param event The servlet context event
+     * 
+     * @param event
+     *            The servlet context event
      */
     public void contextDestroyed(ServletContextEvent event) {
 
-       log("contextDestroyed()");
-       this.context = null;
+        log("contextDestroyed()");
+        this.context = null;
 
     }
 
-
     /**
      * Record the fact that this web application has been initialized.
-     *
-     * @param event The servlet context event
+     * 
+     * @param event
+     *            The servlet context event
      */
     public void contextInitialized(ServletContextEvent event) {
 
-       this.context = event.getServletContext();
-       log("contextInitialized()");
+        this.context = event.getServletContext();
+        log("contextInitialized()");
 
     }
 
-
     /**
      * Record the fact that a session has been created.
-     *
-     * @param event The session event
+     * 
+     * @param event
+     *            The session event
      */
     public void sessionCreated(HttpSessionEvent event) {
 
-       log("sessionCreated('" + event.getSession().getId() + "')");
+        log("sessionCreated('" + event.getSession().getId() + "')");
 
     }
 
-
     /**
      * Record the fact that a session has been destroyed.
-     *
-     * @param event The session event
+     * 
+     * @param event
+     *            The session event
      */
     public void sessionDestroyed(HttpSessionEvent event) {
 
-       log("sessionDestroyed('" + event.getSession().getId() + "')");
+        log("sessionDestroyed('" + event.getSession().getId() + "')");
 
     }
 
-
     // -------------------------------------------------------- Private Methods
 
-
     /**
      * Log a message to the servlet context application log.
-     *
-     * @param message Message to be logged
+     * 
+     * @param message
+     *            Message to be logged
      */
     private void log(String message) {
 
-       if (context != null)
-           context.log("SessionListener: " + message);
-       else
-           System.out.println("SessionListener: " + message);
+        if (context != null)
+            context.log("SessionListener: " + message);
+        else
+            System.out.println("SessionListener: " + message);
 
     }
 
index ffc2737..0bc8739 100644 (file)
@@ -22,14 +22,15 @@ public class servletToJsp extends HttpServlet {
 
     @Override
     public void doGet (HttpServletRequest request,
-                      HttpServletResponse response) {
+            HttpServletResponse response) {
 
-       try {
-           // Set the attribute and Forward to hello.jsp
-           request.setAttribute ("servletName", "servletToJsp");
-           getServletConfig().getServletContext().getRequestDispatcher("/jsp/jsptoserv/hello.jsp").forward(request, response);
-       } catch (Exception ex) {
-           ex.printStackTrace ();
-       }
+       try {
+           // Set the attribute and Forward to hello.jsp
+           request.setAttribute ("servletName", "servletToJsp");
+           getServletConfig().getServletContext().getRequestDispatcher(
+                   "/jsp/jsptoserv/hello.jsp").forward(request, response);
+       } catch (Exception ex) {
+           ex.printStackTrace ();
+       }
     }
 }