dcsimg
Passing object through http from one jvm to another
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   java_naik
Posted On:   Friday, July 12, 2002 11:29 AM

I am trying to pass a java object to a servlet running in different JVM from my perform method (running in separate JVM). My perform method returns Actionforward object redirecting to the same servlet. Here is what I 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.w   More>>

I am trying to pass a java object to a servlet running in different JVM from my perform method (running in separate JVM). My perform method returns Actionforward object redirecting to the same servlet. Here is what I 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?

Thanks    <<Less
About | Sitemap | Contact