[ Team LiB ] Previous Section Next Section

The ServletInputStream Class

When the browser does a POST or a PUT request, a servlet or JSP can use ServletInputStream to read the request body. If the posted data contains form variables, you don't need to use the input stream because the Servlet API automatically reads the variables.

The ServletInputStream class is a subclass of InputStream and adds only one extra method. The readLine method reads a line of data into the byte buffer:


public int readLine(byte[] buffer, int offset, int length)

Use a Reader to Input Character Data

graphics/didyouknow_icon.gif

If you are reading character data, you should be using a BufferedReader rather than the ServletInputStream because the reader performs character conversions properly.


    [ Team LiB ] Previous Section Next Section