Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can i serialize HttpServletResponse and send to javabean

Status
Not open for further replies.

prosper

Programmer
Sep 4, 2001
631
HK
I use JSP to call JavaBean, JavaBean then call the servlet. The servlet then serialize HttpServletResponse and wrap it in a class Addition and send it back to JavaBean.
i have got
org.apache.coyote.tomcat5.CoyoteResponseFacade
and IOException in the servlet
The following is the code in servlet
Code:
package base;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;

public class CookieServlet extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
   System.out.println("para"+request.getQueryString());
   String name = request.getParameter("NAME");
   String value = request.getParameter("VALUE");
   if (name!=null && name.trim().length()>0)
      {
       if (value!=null && value.length()>0)
          {
           System.out.println("within cookie"+name+":"+value);
           Cookie cookie =
           new LongLivedCookie(name, value);    
           response.addCookie(cookie);
          }
      }


try { 

       // create an Object input Stream. 
       Addition A = new Addition(1001,response); 

       response.setContentType("application/octet-stream"); 
       System.out.println("before write");
       ObjectOutputStream oos = 
       new ObjectOutputStream(response.getOutputStream()); 
       oos.writeObject(A); 
       System.out.println("after write");
       oos.flush(); 
       oos.close(); 

         } 
     catch( Exception cnfe){ 
               System.out.println("exception in servlet");
               System.err.println(cnfe.getMessage()); 
    }  
 }

  public void doPost(HttpServletRequest request,
                     HttpServletResponse response)
      throws ServletException, IOException {
     System.out.println("do post");
    doGet(request, response);
  }
}
The following is the debug message
do post
paranull
within cookiename:hello
before write
exception in servlet
org.apache.coyote.tomcat5.CoyoteResponseFacade
ioexception in cookietool post
 
I doubt you will be able to serialize an object that contains a HttpServletResponse - I doubt the class (nor its associated IO streams will allow for it.

Why are you trying to send to the client, an object containing the response object ?


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top