notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1102 - 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: r1102 - trunk/main/planet/http/war/src/main/org/acme
- Date: Wed, 15 Feb 2006 05:35:02 +0100
Author: mcconnell
Date: 2006-02-15 05:34:47 +0100 (Wed, 15 Feb 2006)
New Revision: 1102
Modified:
trunk/main/planet/http/war/src/main/org/acme/Dump.java
Log:
checkstyle
Modified: trunk/main/planet/http/war/src/main/org/acme/Dump.java
===================================================================
--- trunk/main/planet/http/war/src/main/org/acme/Dump.java 2006-02-15
04:03:29 UTC (rev 1101)
+++ trunk/main/planet/http/war/src/main/org/acme/Dump.java 2006-02-15
04:34:47 UTC (rev 1102)
@@ -1,7 +1,7 @@
// ========================================================================
// Copyright 1996-2005 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
-// Licensed under the Apache License, Version 2.0 (the "License");
+// Licensed 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
@@ -32,513 +32,555 @@
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
-
-
-/* ------------------------------------------------------------ */
-/** Dump Servlet Request.
- *
+/**
+ * Dump Servlet Request.
*/
public class Dump 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
{
- request.setAttribute("Dump", this);
- getServletContext().setAttribute("Dump",this);
- getServletContext().log("dump "+request.getRequestURI());
+ request.setAttribute( "Dump", this );
+ getServletContext().setAttribute( "Dump", this );
+ getServletContext().log( "dump " + request.getRequestURI() );
// Force a content length response
- String length= request.getParameter("length");
- if (length != null && length.length() > 0)
+ String length = request.getParameter( "length" );
+ if( ( length != null ) && ( length.length() > 0 ) )
{
- response.setContentLength(Integer.parseInt(length));
+ response.setContentLength( Integer.parseInt( length ) );
}
// Handle a dump of data
- String data= request.getParameter("data");
- String block= request.getParameter("block");
- if (data != null && data.length() > 0)
+ String data = request.getParameter( "data" );
+ String block = request.getParameter( "block" );
+ if( ( data != null ) && ( data.length() > 0 ) )
{
- int d=Integer.parseInt(data);
- int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
- byte[] buf=new byte[b];
- for (int i=0;i<b;i++)
+ int d = Integer.parseInt( data );
+ int b = 50;
+ if( block != null && block.length() > 0 )
{
-
- buf[i]=(byte)('0'+(i%10));
- if (i%10==9)
- buf[i]=(byte)'\n';
+ b = Integer.parseInt( block );
}
- buf[0]='o';
- OutputStream out=response.getOutputStream();
- response.setContentType("text/plain");
- while (d > 0)
+ byte[] buf = new byte[b];
+ for( int i=0; i<b; i++ )
{
- if (d>=b)
+ buf[i] = (byte) ( '0' + ( i%10 ) );
+ if( i%10 == 9 )
{
- out.write(buf);
- d=d-b;
+ buf[i] = (byte) '\n';
}
+ }
+ buf[0] = 'o';
+ OutputStream out = response.getOutputStream();
+ response.setContentType( "text/plain" );
+ while( d > 0 )
+ {
+ if( d >= b )
+ {
+ out.write( buf );
+ d = d-b;
+ }
else
{
- out.write(buf,0,d);
- d=0;
+ out.write( buf, 0, d );
+ d = 0;
}
}
-
return;
}
// handle an exception
- String info= request.getPathInfo();
- if (info != null && info.endsWith("Exception"))
+ String info = request.getPathInfo();
+ if( info != null && info.endsWith( "Exception" ) )
{
try
{
- throw (Throwable)
Thread.currentThread().getContextClassLoader().loadClass(info.substring(1)).newInstance();
+ throw (Throwable)
Thread.currentThread().getContextClassLoader().loadClass( info.substring( 1 )
).newInstance();
}
- catch (Throwable th)
+ catch( Throwable th )
{
- throw new ServletException(th);
+ throw new ServletException( th );
}
}
// handle an redirect
- String redirect= request.getParameter("redirect");
- if (redirect != null && redirect.length() > 0)
+ String redirect = request.getParameter( "redirect" );
+ if( redirect != null && redirect.length() > 0 )
{
- response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
- response.sendRedirect(redirect);
- response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ response.getOutputStream().println( "THIS SHOULD NOT BE SEEN!" );
+ response.sendRedirect( redirect );
+ response.getOutputStream().println( "THIS SHOULD NOT BE SEEN!" );
return;
}
// handle an error
- String error= request.getParameter("error");
- if (error != null && error.length() > 0)
+ String error= request.getParameter( "error" );
+ if( error != null && error.length() > 0 )
{
- response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
- response.sendError(Integer.parseInt(error));
- response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
+ response.getOutputStream().println( "THIS SHOULD NOT BE SEEN!" );
+ response.sendError( Integer.parseInt( error ) );
+ response.getOutputStream().println( "THIS SHOULD NOT BE SEEN!" );
return;
}
+ String buffer= request.getParameter( "buffer" );
+ if( buffer != null && buffer.length() > 0 )
+ {
+ response.setBufferSize( Integer.parseInt( buffer ) );
+ }
+
+ request.setCharacterEncoding( "UTF-8" );
+ response.setContentType( "text/html" );
- String buffer= request.getParameter("buffer");
- if (buffer != null && buffer.length() > 0)
- response.setBufferSize(Integer.parseInt(buffer));
-
- request.setCharacterEncoding("UTF-8");
- response.setContentType("text/html");
-
- if (info != null && info.indexOf("Locale/") >= 0)
+ if( info != null && info.indexOf( "Locale/" ) >= 0 )
{
try
{
- String locale_name= info.substring(info.indexOf("Locale/") +
7);
- Field f= java.util.Locale.class.getField(locale_name);
- response.setLocale((Locale)f.get(null));
+ String localeName = info.substring( info.indexOf( "Locale/"
) + 7 );
+ Field f = java.util.Locale.class.getField( localeName );
+ response.setLocale( (Locale) f.get( null ) );
}
- catch (Exception e)
+ catch( Exception e )
{
e.printStackTrace();
- response.setLocale(Locale.getDefault());
+ response.setLocale( Locale.getDefault() );
}
}
- String cn= request.getParameter("cookie");
- String cv=request.getParameter("value");
- String v=request.getParameter("version");
- if (cn!=null && cv!=null)
+ String cn = request.getParameter( "cookie" );
+ String cv =request.getParameter( "value" );
+ String v =request.getParameter( "version" );
+ if( cn!=null && cv!=null )
{
- Cookie cookie= new Cookie(cn, cv);
- cookie.setComment("Cookie from dump servlet");
- if (v!=null)
+ Cookie cookie = new Cookie( cn, cv );
+ cookie.setComment( "Cookie from dump servlet" );
+ if( v!=null )
{
- cookie.setMaxAge(300);
- cookie.setPath("/");
- cookie.setVersion(Integer.parseInt(v));
+ cookie.setMaxAge( 300 );
+ cookie.setPath( "/" );
+ cookie.setVersion( Integer.parseInt( v ) );
}
- response.addCookie(cookie);
+ response.addCookie( cookie );
}
- String pi= request.getPathInfo();
- if (pi != null && pi.startsWith("/ex"))
+ String pi = request.getPathInfo();
+ if( pi != null && pi.startsWith( "/ex" ) )
{
- OutputStream out= response.getOutputStream();
- out.write("</H1>This text should be reset</H1>".getBytes());
- if ("/ex0".equals(pi))
- throw new ServletException("test ex0", new Throwable());
- if ("/ex1".equals(pi))
- throw new IOException("test ex1");
- if ("/ex2".equals(pi))
- throw new UnavailableException("test ex2");
- throw new RuntimeException("test");
+ OutputStream out = response.getOutputStream();
+ out.write( "</H1>This text should be reset</H1>".getBytes() );
+ if( "/ex0".equals( pi ) )
+ {
+ throw new ServletException( "test ex0", new Throwable() );
+ }
+ if( "/ex1".equals( pi ) )
+ {
+ throw new IOException( "test ex1" );
+ }
+ if( "/ex2".equals( pi ) )
+ {
+ throw new UnavailableException( "test ex2" );
+ }
+ throw new RuntimeException( "test" );
}
-
- PrintWriter pout=null;
+ PrintWriter pout = null;
try
{
- pout =response.getWriter();
+ pout = response.getWriter();
}
- catch(IllegalStateException e)
+ catch( IllegalStateException e )
{
- pout=new PrintWriter(response.getOutputStream());
+ pout = new PrintWriter( response.getOutputStream() );
}
-
try
{
- pout.write("<html>\n<body>\n");
- pout.write("<h1>Dump Servlet</h1>\n");
- pout.write("<table>");
- pout.write("<tr>\n");
- pout.write("<th align=\"right\">getMethod: </th>");
- pout.write("<td>" + request.getMethod()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getContentLength: </th>");
-
pout.write("<td>"+Integer.toString(request.getContentLength())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getContentType: </th>");
- pout.write("<td>"+request.getContentType()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRequestURI: </th>");
- pout.write("<td>"+request.getRequestURI()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRequestURL: </th>");
- pout.write("<td>"+request.getRequestURL()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getContextPath: </th>");
- pout.write("<td>"+request.getContextPath()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getServletPath: </th>");
- pout.write("<td>"+request.getServletPath()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getPathInfo: </th>");
- pout.write("<td>"+request.getPathInfo()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getPathTranslated: </th>");
- pout.write("<td>"+request.getPathTranslated()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getQueryString: </th>");
- pout.write("<td>"+request.getQueryString()+"</td>");
+ pout.write( "<html>\n<body>\n" );
+ pout.write( "<h1>Dump Servlet</h1>\n" );
+ pout.write( "<table>" );
+ pout.write( "<tr>\n" );
+ pout.write( "<th align=\"right\">getMethod: </th>" );
+ pout.write( "<td>" + request.getMethod() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getContentLength: </th>" );
+ pout.write( "<td>" + Integer.toString(
request.getContentLength() ) + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getContentType: </th>" );
+ pout.write( "<td>" + request.getContentType() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getRequestURI: </th>" );
+ pout.write( "<td>" + request.getRequestURI() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getRequestURL: </th>" );
+ pout.write( "<td>" + request.getRequestURL() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getContextPath: </th>" );
+ pout.write( "<td>" + request.getContextPath() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getServletPath: </th>" );
+ pout.write( "<td>" + request.getServletPath() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getPathInfo: </th>" );
+ pout.write( "<td>" + request.getPathInfo() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getPathTranslated: </th>"
);
+ pout.write( "<td>" + request.getPathTranslated() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getQueryString: </th>" );
+ pout.write( "<td>" + request.getQueryString() + "</td>" );
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getProtocol: </th>");
- pout.write("<td>"+request.getProtocol()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getScheme: </th>");
- pout.write("<td>"+request.getScheme()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getServerName: </th>");
- pout.write("<td>"+request.getServerName()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getServerPort: </th>");
-
pout.write("<td>"+Integer.toString(request.getServerPort())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getLocalName: </th>");
- pout.write("<td>"+request.getLocalName()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getLocalAddr: </th>");
- pout.write("<td>"+request.getLocalAddr()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getLocalPort: </th>");
-
pout.write("<td>"+Integer.toString(request.getLocalPort())+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRemoteUser: </th>");
- pout.write("<td>"+request.getRemoteUser()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRemoteAddr: </th>");
- pout.write("<td>"+request.getRemoteAddr()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRemoteHost: </th>");
- pout.write("<td>"+request.getRemoteHost()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getRemotePort: </th>");
- pout.write("<td>"+request.getRemotePort()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">getRequestedSessionId: </th>");
- pout.write("<td>"+request.getRequestedSessionId()+"</td>");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">isSecure(): </th>");
- pout.write("<td>"+request.isSecure()+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getProtocol: </th>" );
+ pout.write( "<td>" + request.getProtocol() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getScheme: </th>" );
+ pout.write( "<td>" + request.getScheme() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getServerName: </th>" );
+ pout.write( "<td>" + request.getServerName() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getServerPort: </th>" );
+ pout.write( "<td>" + Integer.toString( request.getServerPort() )
+ "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getLocalName: </th>" );
+ pout.write( "<td>" + request.getLocalName() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getLocalAddr: </th>" );
+ pout.write( "<td>" + request.getLocalAddr() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getLocalPort: </th>" );
+ pout.write( "<td>"+ Integer.toString( request.getLocalPort() ) +
"</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getRemoteUser: </th>" );
+ pout.write( "<td>" + request.getRemoteUser() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getRemoteAddr: </th>" );
+ pout.write( "<td>" + request.getRemoteAddr() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getRemoteHost: </th>" );
+ pout.write( "<td>" + request.getRemoteHost() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getRemotePort: </th>" );
+ pout.write( "<td>" + request.getRemotePort() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th
align=\"right\">getRequestedSessionId: </th>" );
+ pout.write( "<td>" + request.getRequestedSessionId() + "</td>" );
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">isSecure(): </th>" );
+ pout.write( "<td>" + request.isSecure() + "</td>" );
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">isUserInRole(admin): </th>");
- pout.write("<td>"+request.isUserInRole("admin")+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th
align=\"right\">isUserInRole(admin): </th>" );
+ pout.write( "<td>" + request.isUserInRole( "admin" )+"</td>" );
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getLocale: </th>");
- pout.write("<td>"+request.getLocale()+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getLocale: </th>" );
+ pout.write( "<td>" + request.getLocale() + "</td>" );
Enumeration locales= request.getLocales();
- while (locales.hasMoreElements())
+ while( locales.hasMoreElements() )
{
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">getLocales: </th>");
- pout.write("<td>"+locales.nextElement()+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">getLocales: </th>" );
+ pout.write( "<td>" + locales.nextElement() + "</td>" );
}
- pout.write("</tr><tr>\n");
+ pout.write( "</tr><tr>\n" );
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Other
HTTP Headers:</big></th>");
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Other
HTTP Headers:</big></th>" );
Enumeration h= request.getHeaderNames();
String name;
- while (h.hasMoreElements())
+ while( h.hasMoreElements() )
{
- name= (String)h.nextElement();
+ name = (String) h.nextElement();
- Enumeration h2= request.getHeaders(name);
- while (h2.hasMoreElements())
+ Enumeration h2 = request.getHeaders( name );
+ while( h2.hasMoreElements() )
{
- String hv= (String)h2.nextElement();
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+": </th>");
- pout.write("<td>"+hv+"</td>");
+ String hv = (String) h2.nextElement();
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name +
": </th>" );
+ pout.write( "<td>" + hv + "</td>" );
}
}
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Request
Parameters:</big></th>");
- h= request.getParameterNames();
- while (h.hasMoreElements())
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Request
Parameters:</big></th>" );
+ h = request.getParameterNames();
+ while( h.hasMoreElements() )
{
- name= (String)h.nextElement();
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+": </th>");
- pout.write("<td>"+request.getParameter(name)+"</td>");
- String[] values= request.getParameterValues(name);
- if (values == null)
+ name = (String) h.nextElement();
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + ": </th>" );
+ pout.write( "<td>" + request.getParameter( name ) + "</td>"
);
+ String[] values= request.getParameterValues( name );
+ if( values == null )
{
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+"
Values: </th>");
- pout.write("<td>"+"NULL!"+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + "
Values: </th>" );
+ pout.write( "<td>" + "NULL!" + "</td>" );
}
- else
- if (values.length > 1)
+ else if( values.length > 1 )
+ {
+ for( int i=0; i<values.length; i++ )
{
- for (int i= 0; i < values.length; i++)
- {
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">"+name+"["+i+"]: </th>");
- pout.write("<td>"+values[i]+"</td>");
- }
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + "[" + i
+ "]: </th>" );
+ pout.write( "<td>" + values[i] + "</td>" );
}
+ }
}
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\"
colspan=\"2\"><big><br/>Cookies:</big></th>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\"
colspan=\"2\"><big><br/>Cookies:</big></th>" );
Cookie[] cookies = request.getCookies();
- for (int i=0; cookies!=null && i<cookies.length;i++)
+ for( int i=0; cookies!=null && i<cookies.length; i++ )
{
Cookie cookie = cookies[i];
-
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">"+cookie.getName()+": </th>");
- pout.write("<td>"+cookie.getValue()+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + cookie.getName() +
": </th>" );
+ pout.write( "<td>" + cookie.getValue() + "</td>" );
}
-
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Request
Attributes:</big></th>");
- Enumeration a= request.getAttributeNames();
- while (a.hasMoreElements())
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Request
Attributes:</big></th>" );
+ Enumeration a = request.getAttributeNames();
+ while( a.hasMoreElements() )
{
- name= (String)a.nextElement();
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+": </th>");
- pout.write("<td>"+"<pre>" +
toString(request.getAttribute(name)) + "</pre>"+"</td>");
- }
-
+ name= (String) a.nextElement();
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + ": </th>" );
+ pout.write( "<td>" + "<pre>" + toString(
request.getAttribute( name ) ) + "</pre>"+"</td>" );
+ }
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Servlet
InitParameters:</big></th>");
- a= getInitParameterNames();
- while (a.hasMoreElements())
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Servlet
InitParameters:</big></th>" );
+ a = getInitParameterNames();
+ while( a.hasMoreElements() )
{
- name= (String)a.nextElement();
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+": </th>");
- pout.write("<td>"+"<pre>" + toString(getInitParameter(name))
+ "</pre>"+"</td>");
+ name = (String) a.nextElement();
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + ": </th>" );
+ pout.write( "<td>"+"<pre>" + toString( getInitParameter(
name ) ) + "</pre>"+"</td>" );
}
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Context
InitParameters:</big></th>");
- a= getServletContext().getInitParameterNames();
- while (a.hasMoreElements())
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Context
InitParameters:</big></th>" );
+ a = getServletContext().getInitParameterNames();
+ while( a.hasMoreElements() )
{
- name= (String)a.nextElement();
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+": </th>");
- pout.write("<td>"+"<pre>" +
toString(getServletContext().getInitParameter(name)) + "</pre>"+"</td>");
+ name = (String) a.nextElement();
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + ": </th>" );
+ pout.write( "<td>" + "<pre>" + toString(
getServletContext().getInitParameter( name ) ) + "</pre>" + "</td>" );
}
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Context
Attributes:</big></th>");
- a= getServletContext().getAttributeNames();
- while (a.hasMoreElements())
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Context
Attributes:</big></th>" );
+ a = getServletContext().getAttributeNames();
+ while( a.hasMoreElements() )
{
- name= (String)a.nextElement();
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+name+": </th>");
- pout.write("<td>"+"<pre>" +
toString(getServletContext().getAttribute(name)) + "</pre>"+"</td>");
+ name = (String) a.nextElement();
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"right\">" + name + ": </th>" );
+ pout.write( "<td>"+"<pre>" + toString(
getServletContext().getAttribute( name ) ) + "</pre>" + "</td>" );
}
- String res= request.getParameter("resource");
- if (res != null && res.length() > 0)
+ String res= request.getParameter( "resource" );
+ if( res != null && res.length() > 0 )
{
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Get
Resource:</big></th>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th align=\"left\" colspan=\"2\"><big><br/>Get
Resource:</big></th>" );
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">this.getClass(): </th>");
- pout.write("<td>"+this.getClass().getResource(res)+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th
align=\"right\">this.getClass(): </th>" );
+ pout.write( "<td>" + this.getClass().getResource( res ) +
"</td>" );
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">this.getClass().getClassLoader(): </th>");
-
pout.write("<td>"+this.getClass().getClassLoader().getResource(res)+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th
align=\"right\">this.getClass().getClassLoader(): </th>" );
+ pout.write( "<td>" +
this.getClass().getClassLoader().getResource( res ) + "</td>" );
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">Thread.currentThread().getContextClassLoader(): </th>");
-
pout.write("<td>"+Thread.currentThread().getContextClassLoader().getResource(res)+"</td>");
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th
align=\"right\">Thread.currentThread().getContextClassLoader(): </th>" );
+ pout.write( "<td>" +
Thread.currentThread().getContextClassLoader().getResource( res ) + "</td>" );
- pout.write("</tr><tr>\n");
- pout.write("<th
align=\"right\">getServletContext(): </th>");
-
try{pout.write("<td>"+getServletContext().getResource(res)+"</td>");}
- catch(Exception e) {pout.write("<td>"+"" +e+"</td>");}
+ pout.write( "</tr><tr>\n" );
+ pout.write( "<th
align=\"right\">getServletContext(): </th>" );
+ try
+ {
+ pout.write( "<td>" + getServletContext().getResource(
res ) + "</td>" );
+ }
+ catch( Exception e )
+ {
+ pout.write( "<td>" + "" + e + "</td>" );
+ }
}
- pout.write("</tr></table>\n");
+ pout.write( "</tr></table>\n" );
- /* ------------------------------------------------------------
*/
- pout.write("<h2>Request Wrappers</h2>\n");
- ServletRequest rw=request;
+ pout.write( "<h2>Request Wrappers</h2>\n" );
+ ServletRequest rw = request;
int w=0;
- while (rw !=null)
+ while( rw != null )
{
- pout.write((w++)+": "+rw.getClass().getName()+"<br/>");
- if (rw instanceof HttpServletRequestWrapper)
- rw=((HttpServletRequestWrapper)rw).getRequest();
- else if (rw instanceof ServletRequestWrapper)
- rw=((ServletRequestWrapper)rw).getRequest();
+ pout.write( ( w++ ) + ": " + rw.getClass().getName() +
"<br/>" );
+ if( rw instanceof HttpServletRequestWrapper )
+ {
+ rw = ( (HttpServletRequestWrapper) rw ).getRequest();
+ }
+ else if( rw instanceof ServletRequestWrapper )
+ {
+ rw = ( (ServletRequestWrapper) rw ).getRequest();
+ }
else
+ {
rw=null;
+ }
}
- pout.write("<br/>");
- pout.write("<h2>International Characters</h2>");
- pout.write("Directly encoced: Dürst<br/>");
- pout.write("HTML reference: Dürst<br/>");
- pout.write("Decimal (252) 8859-1: Dürst<br/>");
- pout.write("Hex (xFC) 8859-1: Dürst<br/>");
- pout.write("Javascript unicode (00FC) : <script
language='javascript'>document.write(\"D\u00FCrst\");</script><br/>");
- pout.write("<br/>");
- pout.write("<h2>Form to generate GET content</h2>");
- pout.write("<form method=\"GET\"
action=\""+response.encodeURL(getURI(request))+"\">");
- pout.write("TextField: <input type=\"text\" name=\"TextField\"
value=\"value\"/><br/>\n");
- pout.write("<input type=\"submit\" name=\"Action\"
value=\"Submit\">");
- pout.write("</form>");
+ pout.write( "<br/>" );
+ pout.write( "<h2>International Characters</h2>" );
+ pout.write( "Directly encoced: Dürst<br/>" );
+ pout.write( "HTML reference: Dürst<br/>" );
+ pout.write( "Decimal (252) 8859-1: Dürst<br/>" );
+ pout.write( "Hex (xFC) 8859-1: Dürst<br/>" );
+ pout.write( "Javascript unicode (00FC) : <script
language='javascript'>document.write(\"D\u00FCrst\" );</script><br/>" );
+ pout.write( "<br/>" );
+ pout.write( "<h2>Form to generate GET content</h2>" );
+ pout.write( "<form method=\"GET\" action=\"" +
response.encodeURL( getURI( request ) ) + "\">" );
+ pout.write( "TextField: <input type=\"text\" name=\"TextField\"
value=\"value\"/><br/>\n" );
+ pout.write( "<input type=\"submit\" name=\"Action\"
value=\"Submit\">" );
+ pout.write( "</form>" );
- pout.write("<br/>");
- pout.write("<h2>Form to generate POST content</h2>");
- pout.write("<form method=\"POST\"
action=\""+response.encodeURL(getURI(request))+"\">");
- pout.write("TextField: <input type=\"text\" name=\"TextField\"
value=\"value\"/><br/>\n");
- pout.write("Select: <select multiple name=\"Select\">\n");
- pout.write("<option>ValueA</option>");
- pout.write("<option>ValueB1,ValueB2</option>");
- pout.write("<option>ValueC</option>");
- pout.write("</select><br/>");
- pout.write("<input type=\"submit\" name=\"Action\"
value=\"Submit\"><br/>");
- pout.write("</form>");
+ pout.write( "<br/>" );
+ pout.write( "<h2>Form to generate POST content</h2>" );
+ pout.write( "<form method=\"POST\" action=\"" +
response.encodeURL( getURI( request ) ) + "\">" );
+ pout.write( "TextField: <input type=\"text\" name=\"TextField\"
value=\"value\"/><br/>\n" );
+ pout.write( "Select: <select multiple name=\"Select\">\n" );
+ pout.write( "<option>ValueA</option>" );
+ pout.write( "<option>ValueB1,ValueB2</option>" );
+ pout.write( "<option>ValueC</option>" );
+ pout.write( "</select><br/>" );
+ pout.write( "<input type=\"submit\" name=\"Action\"
value=\"Submit\"><br/>" );
+ pout.write( "</form>" );
- pout.write("<h2>Form to get Resource</h2>");
- pout.write("<form method=\"POST\"
action=\""+response.encodeURL(getURI(request))+"\">");
- pout.write("resource: <input type=\"text\" name=\"resource\"
/><br/>\n");
- pout.write("<input type=\"submit\" name=\"Action\"
value=\"getResource\">");
- pout.write("</form>\n");
+ pout.write( "<h2>Form to get Resource</h2>" );
+ pout.write( "<form method=\"POST\" action=\"" +
response.encodeURL( getURI( request ) ) + "\">" );
+ pout.write( "resource: <input type=\"text\" name=\"resource\"
/><br/>\n" );
+ pout.write( "<input type=\"submit\" name=\"Action\"
value=\"getResource\">" );
+ pout.write( "</form>\n" );
- pout.write("</body>\n</html>\n");
-
+ pout.write( "</body>\n</html>\n" );
}
- catch (Exception e)
+ catch( Exception e )
{
- getServletContext().log("dump", e);
+ getServletContext().log( "dump", e );
}
-
-
+
pout.close();
-
- if (pi != null)
+
+ if( pi != null )
{
- if ("/ex4".equals(pi))
- throw new ServletException("test ex4", new Throwable());
- if ("/ex5".equals(pi))
- throw new IOException("test ex5");
- if ("/ex6".equals(pi))
- throw new UnavailableException("test ex6");
+ if( "/ex4".equals( pi ) )
+ {
+ throw new ServletException( "test ex4", new Throwable() );
+ }
+ if( "/ex5".equals( pi ) )
+ {
+ throw new IOException( "test ex5" );
+ }
+ if( "/ex6".equals( pi ) )
+ {
+ throw new UnavailableException( "test ex6" );
+ }
}
-
-
}
- /* ------------------------------------------------------------ */
+ /**
+ * Return the servlet info.
+ * @return the info
+ */
public String getServletInfo()
{
return "Dump Servlet";
}
- /* ------------------------------------------------------------ */
+ /**
+ * Destroy the servlet.
+ */
public synchronized void destroy()
{
}
- /* ------------------------------------------------------------ */
- private String getURI(HttpServletRequest request)
+ private String getURI( HttpServletRequest request )
{
- String uri=
(String)request.getAttribute("javax.servlet.forward.request_uri");
- if (uri == null)
- uri= request.getRequestURI();
+ String uri= (String) request.getAttribute(
"javax.servlet.forward.request_uri" );
+ if( uri == null )
+ {
+ uri = request.getRequestURI();
+ }
return uri;
}
- /* ------------------------------------------------------------ */
- private static String toString(Object o)
+ private static String toString( Object o )
{
- if (o == null)
+ if( o == null )
+ {
return null;
-
- if (o.getClass().isArray())
+ }
+ if( o.getClass().isArray() )
{
- StringBuffer sb= new StringBuffer();
- Object[] array= (Object[])o;
- for (int i= 0; i < array.length; i++)
+ StringBuffer sb = new StringBuffer();
+ Object[] array = (Object[]) o;
+ for( int i=0; i<array.length; i++ )
{
- if (i > 0)
- sb.append("\n");
- sb.append(array.getClass().getComponentType().getName());
- sb.append("[");
- sb.append(i);
- sb.append("]=");
- sb.append(toString(array[i]));
+ if( i>0 )
+ {
+ sb.append( "\n" );
+ }
+ sb.append( array.getClass().getComponentType().getName() );
+ sb.append( "[" );
+ sb.append( i );
+ sb.append( "]=" );
+ sb.append( toString( array[i] ) );
}
return sb.toString();
}
else
+ {
return o.toString();
+ }
}
-
}
- r1102 - trunk/main/planet/http/war/src/main/org/acme, mcconnell at BerliOS, 02/14/2006
Archive powered by MHonArc 2.6.24.