notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1098 - trunk/main/planet/http/war/src/main/org/acme
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1098 - trunk/main/planet/http/war/src/main/org/acme
- Date: Wed, 15 Feb 2006 04:44:43 +0100
Author: mcconnell
Date: 2006-02-15 04:44:35 +0100 (Wed, 15 Feb 2006)
New Revision: 1098
Modified:
trunk/main/planet/http/war/src/main/org/acme/DispatchServlet.java
trunk/main/planet/http/war/src/main/org/acme/HelloWorld.java
trunk/main/planet/http/war/src/main/org/acme/TestFilter.java
trunk/main/planet/http/war/src/main/org/acme/TestListener.java
Log:
chckstyle
Modified: trunk/main/planet/http/war/src/main/org/acme/DispatchServlet.java
===================================================================
--- trunk/main/planet/http/war/src/main/org/acme/DispatchServlet.java
2006-02-15 03:09:35 UTC (rev 1097)
+++ trunk/main/planet/http/war/src/main/org/acme/DispatchServlet.java
2006-02-15 03:44:35 UTC (rev 1098)
@@ -35,9 +35,6 @@
*/
public class DispatchServlet extends HttpServlet
{
-
- String pageType;
-
/**
* Servlet initialization.
* @param config the servlet config
@@ -104,243 +101,31 @@
if( info.startsWith( "/includeW/" ) )
{
- sres.setContentType( "text/html" );
- info = info.substring( 9 );
- if( info.indexOf( '?' ) < 0 )
- {
- info += "?Dispatch=include";
- }
- else
- {
- info += "&Dispatch=include";
- }
-
- PrintWriter pout = null;
- pout = sres.getWriter();
- pout.write(
- "<H1>Include (writer): "
- + info
- + "</H1><HR>" );
-
- RequestDispatcher dispatch =
- getServletContext().getRequestDispatcher(info);
- if( dispatch == null )
- {
- pout = sres.getWriter();
- pout.write( "<H1>Null dispatcher</H1>" );
- }
- else
- {
- dispatch.include( sreq, sres );
- }
- pout.write( "<HR><H1>-- Included (writer)</H1>" );
+ doGetIncludeW( info, sreq, sres );
}
- else if( info.startsWith("/includeS/" ) )
+ else if( info.startsWith( "/includeS/" ) )
{
- sres.setContentType( "text/html" );
- info = info.substring( 9 );
- if( info.indexOf( '?' ) < 0 )
- {
- info += "?Dispatch=include";
- }
- else
- {
- info += "&Dispatch=include";
- }
-
- OutputStream out = null;
- out = sres.getOutputStream();
- out.write(
- (
- "<H1>Include (outputstream): "
- + info
- + "</H1><HR>"
- ).getBytes()
- );
-
- RequestDispatcher dispatch =
- getServletContext().getRequestDispatcher( info );
- if( dispatch == null )
- {
- out = sres.getOutputStream();
- out.write( "<H1>Null dispatcher</H1>".getBytes() );
- }
- else
- {
- dispatch.include( sreq, sres );
- }
- out.write( "<HR><H1>-- Included (outputstream)</H1>".getBytes()
);
-
+ doGetIncludeS( info, sreq, sres );
}
- else if( info.startsWith("/forward/" ) )
+ else if( info.startsWith( "/forward/" ) )
{
- info= info.substring(8);
- if( info.indexOf('?') < 0 )
- {
- info += "?Dispatch=forward";
- }
- else
- {
- info += "&Dispatch=forward";
- }
-
- RequestDispatcher dispatch =
- getServletContext().getRequestDispatcher( info );
-
- if( dispatch != null )
- {
- ServletOutputStream out = sres.getOutputStream();
- out.print( "Can't see this" );
- dispatch.forward( sreq, sres );
- try
- {
- out.println( "IOException" );
- throw new IllegalStateException();
- }
- catch( IOException e )
- {
- }
- }
- else
- {
- sres.setContentType( "text/html" );
- PrintWriter pout= sres.getWriter();
- pout.write( "<H1>No dispatcher for: " + info + "</H1><HR>" );
- pout.flush();
- }
+ doGetForward( info, sreq, sres );
}
else if( info.startsWith( "/forwardC/" ) )
{
- info = info.substring( 9 );
- if( info.indexOf( '?' ) < 0 )
- {
- info += "?Dispatch=forward";
- }
- else
- {
- info += "&Dispatch=forward";
- }
-
- String cpath = info.substring( 0, info.indexOf( '/', 1 ) );
- info = info.substring( cpath.length() );
- ServletContext context= getServletContext().getContext( cpath );
- RequestDispatcher dispatch = context.getRequestDispatcher( info
);
-
- if( dispatch != null )
- {
- dispatch.forward( sreq, sres );
- }
- else
- {
- sres.setContentType( "text/html" );
- PrintWriter pout = sres.getWriter();
- pout.write(
- "<H1>No dispatcher for: "
- + cpath
- + "/"
- + info
- + "</H1><HR>" );
- pout.flush();
- }
+ doGetForwardC( info, sreq, sres );
}
else if( info.startsWith( "/forwardSC/" ) )
{
- sreq.getSession( true );
- info = info.substring( 10 );
- if( info.indexOf( '?' ) < 0 )
- {
- info += "?Dispatch=forward";
- }
- else
- {
- info += "&Dispatch=forward";
- }
- String cpath = info.substring( 0, info.indexOf( '/', 1 ) );
- info = info.substring( cpath.length() );
-
- ServletContext context = getServletContext().getContext( cpath );
- RequestDispatcher dispatch = context.getRequestDispatcher( info
);
-
- if( dispatch != null )
- {
- dispatch.forward( sreq, sres );
- }
- else
- {
- sres.setContentType( "text/html" );
- PrintWriter pout= sres.getWriter();
- pout.write(
- "<H1>No dispatcher for: "
- + cpath
- + "/"
- + info
- + "</H1><HR>" );
- pout.flush();
- }
+ doGetForwardSC( info, sreq, sres );
}
else if( info.startsWith( "/includeN/" ) )
{
- sres.setContentType( "text/html" );
- info = info.substring( 10 );
- if( info.indexOf( "/" ) >= 0 )
- {
- info= info.substring(0, info.indexOf("/"));
- }
- PrintWriter pout;
- if( info.startsWith( "/null" ) )
- {
- info= info.substring(5);
- }
- else
- {
- pout = sres.getWriter();
- pout.write(
- "<H1>Include named: "
- + info
- + "</H1><HR>" );
- }
-
- RequestDispatcher dispatch =
- getServletContext().getNamedDispatcher( info );
- if( dispatch != null )
- {
- dispatch.include( sreq, sres );
- }
- else
- {
- pout = sres.getWriter();
- pout.write(
- "<H1>No servlet named: "
- + info
- + "</H1>" );
- }
-
- pout = sres.getWriter();
- pout.write( "<HR><H1>Included " );
+ doGetIncludeN( info, sreq, sres );
}
else if( info.startsWith( "/forwardN/" ) )
{
- info = info.substring( 10 );
- if( info.indexOf("/") >= 0 )
- {
- info= info.substring( 0, info.indexOf( "/" ) );
- }
- RequestDispatcher dispatch =
- getServletContext().getNamedDispatcher( info );
- if( dispatch != null )
- {
- dispatch.forward( sreq, sres );
- }
- else
- {
- sres.setContentType( "text/html" );
- PrintWriter pout = sres.getWriter();
- pout.write(
- "<H1>No servlet named: "
- + info
- + "</H1>" );
- pout.flush();
- }
+ doGetForwardN( info, sreq, sres );
}
else
{
@@ -365,6 +150,259 @@
}
}
+ private void doGetIncludeW( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ sres.setContentType( "text/html" );
+ info = info.substring( 9 );
+ if( info.indexOf( '?' ) < 0 )
+ {
+ info += "?Dispatch=include";
+ }
+ else
+ {
+ info += "&Dispatch=include";
+ }
+
+ PrintWriter pout = null;
+ pout = sres.getWriter();
+ pout.write(
+ "<H1>Include (writer): "
+ + info
+ + "</H1><HR>" );
+
+ RequestDispatcher dispatch =
+ getServletContext().getRequestDispatcher(info);
+ if( dispatch == null )
+ {
+ pout = sres.getWriter();
+ pout.write( "<H1>Null dispatcher</H1>" );
+ }
+ else
+ {
+ dispatch.include( sreq, sres );
+ }
+ pout.write( "<HR><H1>-- Included (writer)</H1>" );
+ }
+
+ private void doGetIncludeS( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ sres.setContentType( "text/html" );
+ info = info.substring( 9 );
+ if( info.indexOf( '?' ) < 0 )
+ {
+ info += "?Dispatch=include";
+ }
+ else
+ {
+ info += "&Dispatch=include";
+ }
+
+ OutputStream out = null;
+ out = sres.getOutputStream();
+ out.write(
+ (
+ "<H1>Include (outputstream): "
+ + info
+ + "</H1><HR>"
+ ).getBytes()
+ );
+
+ RequestDispatcher dispatch =
+ getServletContext().getRequestDispatcher( info );
+ if( dispatch == null )
+ {
+ out = sres.getOutputStream();
+ out.write( "<H1>Null dispatcher</H1>".getBytes() );
+ }
+ else
+ {
+ dispatch.include( sreq, sres );
+ }
+ out.write( "<HR><H1>-- Included (outputstream)</H1>".getBytes() );
+ }
+
+ private void doGetForward( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ info = info.substring( 8 );
+ if( info.indexOf( '?' ) < 0 )
+ {
+ info += "?Dispatch=forward";
+ }
+ else
+ {
+ info += "&Dispatch=forward";
+ }
+
+ RequestDispatcher dispatch =
+ getServletContext().getRequestDispatcher( info );
+
+ if( dispatch != null )
+ {
+ ServletOutputStream out = sres.getOutputStream();
+ out.print( "Can't see this" );
+ dispatch.forward( sreq, sres );
+ try
+ {
+ out.println( "IOException" );
+ throw new IllegalStateException();
+ }
+ catch( IOException e )
+ {
+ }
+ }
+ else
+ {
+ sres.setContentType( "text/html" );
+ PrintWriter pout= sres.getWriter();
+ pout.write( "<H1>No dispatcher for: " + info + "</H1><HR>" );
+ pout.flush();
+ }
+ }
+
+ private void doGetForwardC( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ info = info.substring( 9 );
+ if( info.indexOf( '?' ) < 0 )
+ {
+ info += "?Dispatch=forward";
+ }
+ else
+ {
+ info += "&Dispatch=forward";
+ }
+
+ String cpath = info.substring( 0, info.indexOf( '/', 1 ) );
+ info = info.substring( cpath.length() );
+ ServletContext context= getServletContext().getContext( cpath );
+ RequestDispatcher dispatch = context.getRequestDispatcher( info );
+
+ if( dispatch != null )
+ {
+ dispatch.forward( sreq, sres );
+ }
+ else
+ {
+ sres.setContentType( "text/html" );
+ PrintWriter pout = sres.getWriter();
+ pout.write(
+ "<H1>No dispatcher for: "
+ + cpath
+ + "/"
+ + info
+ + "</H1><HR>" );
+ pout.flush();
+ }
+ }
+
+ private void doGetForwardSC( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ sreq.getSession( true );
+ info = info.substring( 10 );
+ if( info.indexOf( '?' ) < 0 )
+ {
+ info += "?Dispatch=forward";
+ }
+ else
+ {
+ info += "&Dispatch=forward";
+ }
+ String cpath = info.substring( 0, info.indexOf( '/', 1 ) );
+ info = info.substring( cpath.length() );
+
+ ServletContext context = getServletContext().getContext( cpath );
+ RequestDispatcher dispatch = context.getRequestDispatcher( info );
+
+ if( dispatch != null )
+ {
+ dispatch.forward( sreq, sres );
+ }
+ else
+ {
+ sres.setContentType( "text/html" );
+ PrintWriter pout= sres.getWriter();
+ pout.write(
+ "<H1>No dispatcher for: "
+ + cpath
+ + "/"
+ + info
+ + "</H1><HR>" );
+ pout.flush();
+ }
+ }
+
+ private void doGetIncludeN( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ sres.setContentType( "text/html" );
+ info = info.substring( 10 );
+ if( info.indexOf( "/" ) >= 0 )
+ {
+ info = info.substring(0, info.indexOf( "/" ) );
+ }
+ PrintWriter pout;
+ if( info.startsWith( "/null" ) )
+ {
+ info = info.substring( 5 );
+ }
+ else
+ {
+ pout = sres.getWriter();
+ pout.write(
+ "<H1>Include named: "
+ + info
+ + "</H1><HR>" );
+ }
+
+ RequestDispatcher dispatch =
+ getServletContext().getNamedDispatcher( info );
+ if( dispatch != null )
+ {
+ dispatch.include( sreq, sres );
+ }
+ else
+ {
+ pout = sres.getWriter();
+ pout.write(
+ "<H1>No servlet named: "
+ + info
+ + "</H1>" );
+ }
+
+ pout = sres.getWriter();
+ pout.write( "<HR><H1>Included " );
+ }
+
+ private void doGetForwardN( String info, HttpServletRequest sreq,
HttpServletResponse sres )
+ throws ServletException, IOException
+ {
+ info = info.substring( 10 );
+ if( info.indexOf( "/" ) >= 0 )
+ {
+ info= info.substring( 0, info.indexOf( "/" ) );
+ }
+ RequestDispatcher dispatch =
+ getServletContext().getNamedDispatcher( info );
+ if( dispatch != null )
+ {
+ dispatch.forward( sreq, sres );
+ }
+ else
+ {
+ sres.setContentType( "text/html" );
+ PrintWriter pout = sres.getWriter();
+ pout.write(
+ "<H1>No servlet named: "
+ + info
+ + "</H1>" );
+ pout.flush();
+ }
+ }
+
/**
* Return thr servlet info.
* @return the info
Modified: trunk/main/planet/http/war/src/main/org/acme/HelloWorld.java
===================================================================
--- trunk/main/planet/http/war/src/main/org/acme/HelloWorld.java
2006-02-15 03:09:35 UTC (rev 1097)
+++ trunk/main/planet/http/war/src/main/org/acme/HelloWorld.java
2006-02-15 03:44:35 UTC (rev 1098)
@@ -24,34 +24,50 @@
import javax.servlet.http.HttpServletResponse;
-/* ------------------------------------------------------------ */
-/** Dump Servlet Request.
- *
+/**
+ * Hello World Servlet
*/
public class HelloWorld extends HttpServlet
{
- /* ------------------------------------------------------------ */
- public void init(ServletConfig config) throws ServletException
+ /**
+ * Servlet initialization.
+ * @param config the servlet configuration
+ * @exception ServletException if a configuration error occurs
+ */
+ public void init( ServletConfig config ) throws ServletException
{
- super.init(config);
+ super.init( config );
}
- /* ------------------------------------------------------------ */
- public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
+ /**
+ * Process an incomming post request.
+ * @param request the http request
+ * @param response the http response
+ * @exception ServletException if a servlet processing error occurs
+ * @exception IOException if an IO error occurs
+ */
+ public void doPost( HttpServletRequest request, HttpServletResponse
response )
+ throws ServletException, IOException
{
- doGet(request, response);
+ doGet( request, response );
}
- /* ------------------------------------------------------------ */
- public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
+ /**
+ * Process an incomming get request.
+ * @param request the http request
+ * @param response the http response
+ * @exception ServletException if a servlet processing error occurs
+ * @exception IOException if an IO error occurs
+ */
+ public void doGet( HttpServletRequest request, HttpServletResponse
response )
+ throws ServletException, IOException
{
- response.setContentType("text/html");
+ response.setContentType( "text/html" );
ServletOutputStream out = response.getOutputStream();
- out.println("<html>");
- out.println("<h1>Hello World<h1>");
- out.println("Blah blah blah.");
- out.println("</html>");
+ out.println( "<html>" );
+ out.println( "<h1>Hello World<h1>" );
+ out.println( "Blah blah blah." );
+ out.println( "</html>" );
out.flush();
}
-
}
Modified: trunk/main/planet/http/war/src/main/org/acme/TestFilter.java
===================================================================
--- trunk/main/planet/http/war/src/main/org/acme/TestFilter.java
2006-02-15 03:09:35 UTC (rev 1097)
+++ trunk/main/planet/http/war/src/main/org/acme/TestFilter.java
2006-02-15 03:44:35 UTC (rev 1098)
@@ -64,7 +64,7 @@
Integer value = null;
if( null == oldValue )
{
- value = new Integer(1);
+ value = new Integer( 1 );
}
else
{
Modified: trunk/main/planet/http/war/src/main/org/acme/TestListener.java
===================================================================
--- trunk/main/planet/http/war/src/main/org/acme/TestListener.java
2006-02-15 03:09:35 UTC (rev 1097)
+++ trunk/main/planet/http/war/src/main/org/acme/TestListener.java
2006-02-15 03:44:35 UTC (rev 1098)
@@ -29,89 +29,160 @@
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
+/**
+ * Test listeners.
+ */
public class TestListener implements HttpSessionListener,
HttpSessionAttributeListener, HttpSessionActivationListener,
ServletContextListener, ServletContextAttributeListener,
ServletRequestListener, ServletRequestAttributeListener
{
- public void attributeAdded(HttpSessionBindingEvent se)
+ /**
+ * Attribute added.
+ * @param se binding event
+ */
+ public void attributeAdded( HttpSessionBindingEvent se )
{
// System.err.println("attributedAdded "+se);
}
- public void attributeRemoved(HttpSessionBindingEvent se)
+ /**
+ * Attribute removed.
+ * @param se binding event
+ */
+ public void attributeRemoved( HttpSessionBindingEvent se )
{
// System.err.println("attributeRemoved "+se);
}
- public void attributeReplaced(HttpSessionBindingEvent se)
+ /**
+ * Attribute replaced.
+ * @param se binding event
+ */
+ public void attributeReplaced( HttpSessionBindingEvent se )
{
// System.err.println("attributeReplaced "+se);
}
- public void sessionWillPassivate(HttpSessionEvent se)
+ /**
+ * Session passivate notification
+ * @param se session event
+ */
+ public void sessionWillPassivate( HttpSessionEvent se )
{
// System.err.println("sessionWillPassivate "+se);
}
- public void sessionDidActivate(HttpSessionEvent se)
+ /**
+ * Session did activate notification
+ * @param se session event
+ */
+ public void sessionDidActivate( HttpSessionEvent se )
{
// System.err.println("sessionDidActivate "+se);
}
- public void contextInitialized(ServletContextEvent sce)
+ /**
+ * Context initiated notification
+ * @param sce servlet context event
+ */
+ public void contextInitialized( ServletContextEvent sce )
{
// System.err.println("contextInitialized "+sce);
}
- public void contextDestroyed(ServletContextEvent sce)
+ /**
+ * Context destroy notification
+ * @param sce servlet context event
+ */
+ public void contextDestroyed( ServletContextEvent sce )
{
// System.err.println("contextDestroyed "+sce);
}
- public void attributeAdded(ServletContextAttributeEvent scab)
+ /**
+ * Attribute added notification
+ * @param scab servlet context attribute event
+ */
+ public void attributeAdded( ServletContextAttributeEvent scab )
{
// System.err.println("attributeAdded "+scab);
}
- public void attributeRemoved(ServletContextAttributeEvent scab)
+ /**
+ * Attribute removed notification
+ * @param scab servlet context attribute event
+ */
+ public void attributeRemoved( ServletContextAttributeEvent scab )
{
// System.err.println("attributeRemoved "+scab);
}
- public void attributeReplaced(ServletContextAttributeEvent scab)
+ /**
+ * Attribute replaced notification
+ * @param scab servlet context attribute event
+ */
+ public void attributeReplaced( ServletContextAttributeEvent scab )
{
// System.err.println("attributeReplaced "+scab);
}
- public void requestDestroyed(ServletRequestEvent sre)
+ /**
+ * Request destroyed notification
+ * @param sre servlet request event
+ */
+ public void requestDestroyed( ServletRequestEvent sre )
{
// System.err.println("requestDestroyed "+sre);
}
- public void requestInitialized(ServletRequestEvent sre)
+ /**
+ * Request initialized notification
+ * @param sre servlet request event
+ */
+ public void requestInitialized( ServletRequestEvent sre )
{
// System.err.println("requestInitialized "+sre);
}
- public void attributeAdded(ServletRequestAttributeEvent srae)
+ /**
+ * Attribute added notification
+ * @param srae servlet request attribute event
+ */
+ public void attributeAdded( ServletRequestAttributeEvent srae )
{
// System.err.println("attributeAdded "+srae);
}
- public void attributeRemoved(ServletRequestAttributeEvent srae)
+ /**
+ * Attribute removed notification
+ * @param srae servlet request attribute event
+ */
+ public void attributeRemoved( ServletRequestAttributeEvent srae )
{
// System.err.println("attributeRemoved "+srae);
}
- public void attributeReplaced(ServletRequestAttributeEvent srae)
+ /**
+ * Attribute replaced notification
+ * @param srae servlet request attribute event
+ */
+ public void attributeReplaced( ServletRequestAttributeEvent srae )
{
// System.err.println("attributeReplaced "+srae);
}
- public void sessionCreated(HttpSessionEvent se)
+ /**
+ * Session created notification
+ * @param se session event
+ */
+ public void sessionCreated( HttpSessionEvent se )
{
// System.err.println("sessionCreated "+se);
}
- public void sessionDestroyed(HttpSessionEvent se)
+ /**
+ * Session destroyed notification
+ * @param se session event
+ */
+ public void sessionDestroyed( HttpSessionEvent se )
{
// System.err.println("sessionDestroyed "+se);
}
- r1098 - trunk/main/planet/http/war/src/main/org/acme, mcconnell at BerliOS, 02/14/2006
Archive powered by MHonArc 2.6.24.