servlet objectinputstream eofexception

The constructor for ObjectInputStream reads some header

information from the serialized stream, and if the stream doesn't contain this

header information you could easily get an EOFException.  This is what I do in

my service() method:


 public void service(ServletRequest request, ServletResponse response)

    throws ServletException, IOException {


   if ( request.getContentLength() > 0 &&

        "application/octet-stream".equals(request.getContentType())) {


     ObjectInputStream inputStream =

         new ObjectInputStream(request.getInputStream());


even this only provides limited protection.


發佈了54 篇原創文章 · 獲贊 10 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章