FileDocCategorySizeDatePackage
ServletOutputStream.javaAPI DocGlassfish v2 API9489Fri May 04 22:34:20 BST 2007javax.servlet

ServletOutputStream

public abstract class ServletOutputStream extends OutputStream
Provides an output stream for sending binary data to the client. A ServletOutputStream object is normally retrieved via the {@link ServletResponse#getOutputStream} method.

This is an abstract class that the servlet container implements. Subclasses of this class must implement the java.io.OutputStream.write(int) method.

author
Various
see
ServletResponse

Fields Summary
private static final String
LSTRING_FILE
private static ResourceBundle
lStrings
Constructors Summary
protected ServletOutputStream()
Does nothing, because this is an abstract class.



    
                 

       
Methods Summary
public voidprint(java.lang.String s)
Writes a String to the client, without a carriage return-line feed (CRLF) character at the end.

param
s the String to send to the client
exception
IOException if an input or output exception occurred

	if (s==null) s="null";
	int len = s.length();
	for (int i = 0; i < len; i++) {
	    char c = s.charAt (i);

	    //
	    // XXX NOTE:  This is clearly incorrect for many strings,
	    // but is the only consistent approach within the current
	    // servlet framework.  It must suffice until servlet output
	    // streams properly encode their output.
	    //
	    if ((c & 0xff00) != 0) {	// high order byte must be zero
		String errMsg = lStrings.getString("err.not_iso8859_1");
		Object[] errArgs = new Object[1];
		errArgs[0] = new Character(c);
		errMsg = MessageFormat.format(errMsg, errArgs);
		throw new CharConversionException(errMsg);
	    }
	    write (c);
	}
    
public voidprint(boolean b)
Writes a boolean value to the client, with no carriage return-line feed (CRLF) character at the end.

param
b the boolean value to send to the client
exception
IOException if an input or output exception occurred

	String msg;
	if (b) {
	    msg = lStrings.getString("value.true");
	} else {
	    msg = lStrings.getString("value.false");
	}
	print(msg);
    
public voidprint(char c)
Writes a character to the client, with no carriage return-line feed (CRLF) at the end.

param
c the character to send to the client
exception
IOException if an input or output exception occurred

	print(String.valueOf(c));
    
public voidprint(int i)
Writes an int to the client, with no carriage return-line feed (CRLF) at the end.

param
i the int to send to the client
exception
IOException if an input or output exception occurred

	print(String.valueOf(i));
    
public voidprint(long l)
Writes a long value to the client, with no carriage return-line feed (CRLF) at the end.

param
l the long value to send to the client
exception
IOException if an input or output exception occurred

	print(String.valueOf(l));
    
public voidprint(float f)
Writes a float value to the client, with no carriage return-line feed (CRLF) at the end.

param
f the float value to send to the client
exception
IOException if an input or output exception occurred

	print(String.valueOf(f));
    
public voidprint(double d)
Writes a double value to the client, with no carriage return-line feed (CRLF) at the end.

param
d the double value to send to the client
exception
IOException if an input or output exception occurred

	print(String.valueOf(d));
    
public voidprintln(java.lang.String s)
Writes a String to the client, followed by a carriage return-line feed (CRLF).

param
s the String to write to the client
exception
IOException if an input or output exception occurred

	print(s);
	println();
    
public voidprintln(boolean b)
Writes a boolean value to the client, followed by a carriage return-line feed (CRLF).

param
b the boolean value to write to the client
exception
IOException if an input or output exception occurred

	print(b);
	println();
    
public voidprintln(char c)
Writes a character to the client, followed by a carriage return-line feed (CRLF).

param
c the character to write to the client
exception
IOException if an input or output exception occurred

	print(c);
	println();
    
public voidprintln(int i)
Writes an int to the client, followed by a carriage return-line feed (CRLF) character.

param
i the int to write to the client
exception
IOException if an input or output exception occurred

	print(i);
	println();
    
public voidprintln(long l)
Writes a long value to the client, followed by a carriage return-line feed (CRLF).

param
l the long value to write to the client
exception
IOException if an input or output exception occurred

	print(l);
	println();
    
public voidprintln(float f)
Writes a float value to the client, followed by a carriage return-line feed (CRLF).

param
f the float value to write to the client
exception
IOException if an input or output exception occurred

	print(f);
	println();
    
public voidprintln(double d)
Writes a double value to the client, followed by a carriage return-line feed (CRLF).

param
d the double value to write to the client
exception
IOException if an input or output exception occurred

	print(d);
	println();
    
public voidprintln()
Writes a carriage return-line feed (CRLF) to the client.

exception
IOException if an input or output exception occurred

	print("\r\n");