public static class DynamicMappingFilter.TempBufferWriter
extends java.io.Writer
A Writer
that passes characters to a PrintWriter
. It buffers the first
N
characters written to it and automatically overflows when the number of characters
written exceeds the limit. The size of the buffer defaults to 1024 characters, but it can be
changed using the IncludeBufferSize
filter init-param in web.xml
. If
IncludeBufferSize
is zero or negative, then a DynamicMappingFilter.TempBufferWriter
will not be
used at all. This is only a good idea if your servlet container does not write an error
message to output when it can't find an included resource or if you only include resources
that do not depend on this filter to be delivered, such as other servlets, JSPs, static
resources, ActionBeans that are mapped with a prefix (/action/*
) or suffix (*.action
),
etc.
This writer is used to partially buffer the output of includes. Some (all?) servlet
containers write a message to the output stream indicating if an included resource is missing
because if the response has already been committed, they cannot send a 404 error. Since the
filter depends on getting a 404 before it attempts to dispatch an ActionBean
, that
is problematic. So in using this writer, we assume that the length of the "missing resource"
message will be less than the buffer size and we discard that message if we're able to map
the included URL to an ActionBean
. If there is no 404 then the output will be sent
normally. If there is a 404 and the URL does not match an ActionBean then the "missing
resource" message is sent through.
Constructor and Description |
---|
DynamicMappingFilter.TempBufferWriter(java.io.PrintWriter out) |
public DynamicMappingFilter.TempBufferWriter(java.io.PrintWriter out)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
public void write(char[] chars, int offset, int length) throws java.io.IOException
write
in class java.io.Writer
java.io.IOException
protected void overflow()
overflow()
, all future writes to this writer will pass directly to the
underlying writer.? Copyright 2005-2006, Stripes Development Team.