use the inputstream to write to a file and to process.
Hi
I have a servlet that uses the HttpServletRequest stream, req.getInputStream(),
to write to a file and to process data. The way I understand is that once
you use it the input stream buffer is clear. Is there a way to use one input
stream to do both tasks?
Here is the code.
public class AcceptorWeb extends FWServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
res.setContentType( "text/html" );
writeToFile( req.getInputStream() );
acceptFormData( req.getInputStream() );
}
public void writeToFile(InputStream is) throws Exception
{
}
public void acceptFormData(InputStream is) throws Exception
{
}
}
Re: use the inputstream to write to a file and to process.
processData( req.getInputStream() );
}
public void processData(InputStream is)
{
// read a line of data
// write it to the file
// do whatever acceptFormData does with the line
// repeat this until you reach the end of the stream
}
"Quan Ha" <qha@fedworld.gov> wrote in message
news:3bf27a2e$1@147.208.176.211...
>
> Hi
> I have a servlet that uses the HttpServletRequest stream,
req.getInputStream(),
> to write to a file and to process data. The way I understand is that once
> you use it the input stream buffer is clear. Is there a way to use one
input
> stream to do both tasks?
>
> Here is the code.
>
> public class AcceptorWeb extends FWServlet
> {
> public void doGet(HttpServletRequest req, HttpServletResponse res)
throws
> ServletException, IOException
> {
>
> res.setContentType( "text/html" );
>
> writeToFile( req.getInputStream() );
> acceptFormData( req.getInputStream() );
>
> }
>
> public void writeToFile(InputStream is) throws Exception
> {
> }
>
> public void acceptFormData(InputStream is) throws Exception
> {
> }
>
> }
>