You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by java naik <ja...@yahoo.com> on 2002/07/16 02:39:04 UTC

Object passing to another jvm from perform

I am trying to pass a java object from my perform method to a servlet 
running in different JVM . 

My perform method returns Actionforward object redirecting to the same 
servlet. Here is what I have tried: 

Perform method:

Object resultObj = getObj();

URL url= new URL("http://localhost:8080/CallbackServlet");
URLConnection uConn = url.openConnection();

uConn.setDoOutput(true);
uConn.setAllowUserInteraction(false);
uConn.setUseCaches(false);
uConn.setDefaultUseCaches(false);

ObjectOutputStream outputToHost = new 
ObjectOutputStream(uConn.getOutputStream());
outputToHost.writeObject(resultObj);
outputToHost.flush();
outputToHost.close();

String callbackClassName = (String) 
session.getAttribute(Constants.CALLBACK_CLASS);
String callbackClassInvokerURL = 
"http://localhost:8080/CallbackServlet?callbackClassName="+callbackClassName;

if(callbackClassInvokerURL != null) {
    TxActionForward af = new TxActionForward( callbackClassInvokerURL 
);
    af.setRedirect(true);
    return af;
}

and the CallbackServlet: Service method

ServletInputStream si = request.getInputStream();
// get object to be viewed
ObjectInputStream inputFromClient = new 
ObjectInputStream((InputStream)si);
Object resultObj = null;
resultObj = (Object)inputFromClient.readObject();
inputFromClient.close();


This did not work. It never comes out of the following statement
// get object to be viewed ObjectInputStream inputFromClient = new 
ObjectInputStream((InputStream)si); 
Could anyone explain what's wrong in the above program? or please 
suggest some other route? 


---------------------------------
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes