• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalStateException

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is output of the following code : thnx in advance.

1.public class UploadServlet extends HttpServlet {
2. protected void doGet(HttpServletRequest req, HttpServletResponse resp)
3. throws ServletException, IOException {
4. byte[] someBytes = new byte[1];
5. someBytes[0] = '1';
6. OutputStream os = resp.getOutputStream();
7. os.write(someBytes);
8. PrintWriter pw = resp.getWriter();
9. pw.println (" Succeeded");
10. os.flush();
11. }
12.}
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not try it yourself ? It's a good exercice.
Anyway, you cannot get the output stream twice, so you'll get an error at getWriter. Check out where flush() is called.

Have a look at getOutputStream() and getWriter() in the API.
It says it all about getting the output stream and flush().
[ December 26, 2005: Message edited by: Satou kurinosuke ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic