Help!!! Sending serialized object to another server/servlet

I am trying to simply send a serialized bean to a servlet on another server. I have lot's of examples of doing this as a stream and recieving back a stream to output, trouble is, I want to do this as a means of communicating the state of a process from one application kicking off the process on the new application. So when the page is returned, I need to be located on the new server. Here is the stream code I'm using:
String strUrl = "http://www.myurl.net";
try {
     URL url = new URL(strUrl);
     HttpMessage msg = new HttpMessage(url);
     BufferedReader in;
     Object beanObj = (Object) myBean;
     MyBean beany = (MyBean) beanObj;
     in = new BufferedReader(new InputStreamReader(msg.sendPostMessage(beany)));
     String inputLine;
     while ((inputLine = in.readLine()) != null) {
     out.println(inputLine + "\n");
     in.close();
catch(IOException io) {
out.println("Unable to call the servlet " + io);
out.close();
How would I do this if I wanted to send and not come back to the original server?

Why not create a little daemon to run on Server B (using the Servlet API would make this really easy) that listens for requests from Server A. The Servlet running on Server A would:
1. Do whatever it needs to do
2. Open an HttpURLConnection to Server B, use the getOutputStream() method to get a pipe to write serialized data to, couple it with an ObjectOutputStream, and write the session object to it.
3. Use the sendRedirect() method to redirect the client to Server B.
Upon receiving a request, the Servlet on Server B would:
1. Call Servlet.getInputStream() to get the input stream to read objects from.
2. Couple this with an ObjectInputStream to read objects from.
3. Read the session object and cast it to the appropriate type.
4. Stash the session object in a global lookup so it can be retrieved when the client arrives. I don't think the session can be created at this point because the request doesn't originate from the browser.
Then, finally, the Servlet running on Server B that handles client requests would:
1. Create a new session
2. Retrieve the session object from the global data store and stash it in session.
3. Go on its merry way.
Hope this was on target and is useful.

Similar Messages

  • Problem while sending seriailized  object from applet to servlet

    Hi I m having Object communication between Applet and Servlet.
    I m getting error stack trace as
    java.io.EOFException
         at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
    at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
         at java.io.ObjectInputStream.<init>(Unknown Source)
         at com.chat.client.ObjectClient.write(ObjectClient.java:56)
    at the line
    ObjectInputStream ois = new ObjectInputStream(conn.getInputStream());
    thanks in advance
    Ravi
    the whole code is as follows....
    public Serializable write(Serializable obj) throws IOException,ClassNotFoundException{
              URLConnection conn = serverURL.openConnection();
              conn.setDoOutput(true);
              conn.setDoInput(true);
              conn.setUseCaches(false);
              conn.setRequestProperty("Content-Type", "java-internal/"+obj.getClass().getName());
              conn.connect();
              ObjectOutputStream oos= null;
              try{
              oos = new ObjectOutputStream(
                   conn.getOutputStream());
                        oos.writeObject(obj);
                   catch(Exception ee){
                                       ee.printStackTrace();
                   finally{
                        if(oos!=null){
                             oos.flush();
                             oos.close();
                        return the reponse to the client
                   ObjectInputStream ois=null;
                   try{
    \\this is the line where i m getting the error               
    ois = new ObjectInputStream(conn.getInputStream());
                             return (Serializable)ois.readObject();
                        catch(Exception ee){
                                            System.out.println("Error in Object Client inputstream ");
                                            ee.printStackTrace();
                                            return null;
                        finally{
                             if(ois!=null){
                                  ois.close();

    Did anyone find a fix to this problem. I am having a similiar problem. Sometimes I receive an EOFException and othertimes I don't. When I do receive an EOFException I check for available() in the stream and it appears 0 bytes were sent to the Servlet from the Applet.
    I am always open to produce this problem when I use File->New in IE my applet loads on the new page.. and then I navigate to a JSP sitting on the same application server. When I go to the Applet on the initial page and try to send an object to the server I get an EOFException. No idea!

  • Continuously send serialized objects from servlet

    Hi,
    I'm trying to write a servlet that, once activated, will continuously send objects back to a thread in the client. I'm hoping someone can point me in the right direction. This code works fine if you take out the while(true){...} loops.
    After doing a bit more research, I discovered the OutputObjectStream should be .reset() in order to reset the object map. I tried doing this before the .flush() with no success. The servlet continues to spew out objects, but the client side doesn't even see the first one, hanging on the in = DataInputStream(connection.getInputStream()) line.
    Servlet code:
    public class testStream extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    int[] somedata = new int [1];
    somedata [0] = 1000;
    String contentType =
    "application/x-java-serialized-object";
    response.setContentType(contentType);
    ObjectOutputStream out =
    new ObjectOutputStream(response.getOutputStream());
    while (true) {
    try {
    out.writeObject(somedata );
    System.out.println("Sent " + somedata [0]);
    somedata [0]++;
    } catch(Exception ie) {}
    out.flush();
    Thread.yield();
    out.close(); // unreachable if while loop in place
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    Applet side code:
    * <P>
    * Taken from Core Servlets and JavaServer Pages
    * from Prentice Hall and Sun Microsystems Press,
    * http://www.coreservlets.com/.
    * � 2000 Marty Hall; may be freely used or adapted.
    public class testStream implements Runnable {
    private boolean isDone = false;
    private URL dataURL;
    public testStream(String urlSuffix, URL currentPage) {
    try {
    // Only the URL suffix need be supplied, since
    // the rest of the URL is derived from the current page.
    String protocol = currentPage.getProtocol();
    String host = currentPage.getHost();
    int port = currentPage.getPort();
    dataURL = new URL(protocol, host, port, urlSuffix);
    Thread imageRetriever = new Thread(this);
    imageRetriever.start();
    } catch(MalformedURLException mfe) {
    System.err.println("Bad URL");
    isDone = true;
    public void run() {
    try {
    retrieveImage();
    } catch(IOException ioe) {
    isDone = true; // will never get hit
    public boolean isDone() { // meaningless now with infinite loop
    return(isDone);
    private void retrieveImage() throws IOException {
    URLConnection connection = dataURL.openConnection();
    connection.setUseCaches(false);
    connection.setDoInput(true);
    connection.setDefaultUseCaches (false);
    connection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
    ObjectInputStream in = null;
    try {
    in = new ObjectInputStream(connection.getInputStream());
    } catch (Exception pe) { System.err.println(pe); }
    while (true) {
    // loop forever requesting data
    try {
    // The return type of readObject is Object, so
    // I need a typecast to the actual type.
    int[] someData = (int[]) in.readObject();
    System.err.println(someData[0]);
    } catch(ClassNotFoundException cnfe) {
    System.err.println("received NULL");
    Thread.yield();

    try this: move out.flush() upwards directly after the out.writeObject().
    robert

  • Sending request object to another application

    Hi
    Is there any possibility to send request object from one Application context to another application context.
    We have two JEE enterprise application that deployed on different application server I want to know if there is any possibilty to send request object to them or not?
    I don't like to redirect reuqest because I want to put some value in req body (POST method)

    It is possible to get a request dispatcher to a servlet in another context by first getting the other context's ServletContext object. For example, in the original servlet's doPost method::
        ServletContext otherContext = this.getServletContext().getServletContext(uriToSecondContext);
        RequestDispatcher dispatcher = otherContext.getRequestDispatcher(uriToForwardTo)
        dispatcher.forward(request, response);In order to work both applications have to be configured to be allowed Cross Context access. In Tomcat you do this in the <Context ...> element of the configuration XML file by defining the crossContext attribute to "true".

  • How to send multiple objects from appleto to servlet and vice versa

    how can i send multiple objects(ArrayLists and String) from servlet to applet and applet to servlet?

    Use an HTTPUrlConnection from the Applet to the Servlet to send data to the server, or request information from the servlet. To actually transfer the objects you will have to use a serialized version of the objects, almost always by wrapping the streams generated via the UrlConnection in ObjectOutputStream and ObjectInputStreams.

  • Bizarre ClassCastException when sending serialized objects

    I have two programs communicating with each other over a network using TCP and serialized objects. One of the programs uses an ObjectOutputStream to send the message, and the other uses an ObjectInputStream to receive it. The receiver has a thread that simply loops, receiving and processing messages one at a time.
    Under normal circumstances, this works fine. However, sometimes the sender program has to send more than one message, one right after the other. I guess my assumption was that on the receiving end, they would somehow just "queue up" in the ObjectInputStream and the receiver would be able to read them one at a time. But instead, I get this bizarre ClassCastException whose message talks about members and objects from both messages that were sent. It is as though somehow the two objects received are being mangled together and interpreted somehow as one object. This is strange to me, since I am pretty sure TCP is supposed to guarantee in-order delivery of packets.
    Can I not send multiple messages right after each other through an ObjectOutputStream and have them received in an ObjectInputStream? If not, what would be a good workaround?
    If you need more details, it works like this. I have two classes that look like this:
    class Class1 extends SerializableSuperclass
      Member1 m1;
    class Class2 extends SerializableSuperclass
      Member2 m2;
    }Sender sends an instance of Class1 and then immediately an instance of Class2. Receiver attempts to readObject() from the input stream and gets this exception:
    Exception in thread "Thread-4" java.lang.ClassCastException: cannot assign instance of Class2 to field Class1.m1 of type Member1 in instance Class1
    Isn't that bizarre? Two separate classes, and it is attempting to merge the two in some odd way.
    How do I fix or work around this?
    Thanks

    These classes do not have those methods. They are simply message classes designed to hold data. Do you need to see the methods that call ObjectOutputStream's writeObject() and ObjectInputStream's readObject() methods?
    The serializable superclass is there because it has other stuff including a field identifying the sender. It's basically a base message class.
    Also, the member classes are serializable (serializability isn't the issue anyway; "class cast" is the issue).

  • Need help placing people / objects into another photo ...realistically

    Hi, I've been a Photoshop user for many years now and have adopted CS4 when it initially came available. My photoshop skills are to a good standard however one thing I always find difficult is taking a selection from one photo (usually a person / object) and placing it into another photo.
    I am able to correct the size and scale and maintain the aspect ratio but I never seem to be able to make the photo look convincing, I know this is a basic part of Photoshop, but I was wondering if any of you could offer some tips or advice on how to make the person / object more realistic and hopefully so that clients won't be able to spot it was missing in the first place.
    Thanks in advance

    The Daily show is a satirical show in the US with John Stewart. As a kind of running joke on "Photoshopped", they often badly photoshop things together, cut and paste style.
    Whether things will ever look correct, is to do with LIGHT. The light on your background has to be the same as the light on your foreground subjects. Color can be easily tweaked and matched but light cannot. Photographers with the right expertise (thinner on the ground than you might think) can look at the light in a destination image, and try and match in the studio, but this is a highly skilled area. I once had a professional job where someone had taken David Beckham to a studio - and they wanted the images realistically comped into beach scenes, with broad sunshine, resulting hard shadows, sunsets and horizons. Unfortunately the photographer was obviously more interested in having fun with a high profile client like Beckham for their book, than they were in lighting correcty for the intended destination images.  Impossible without weeks of painting, and I told them. No point in wasting clients time on images like this.

  • Callable Object from another server?

    Is there any way of setting up a Web Dynpro application or component as a callable object in GP that was deployed to a server other than the portal server?  Our WD apps and components will not be living on the portal server but we would like to set them up as callable objects within GP.
    Thanks,
    Cindy

    This is the document I followed to create a WD callable object.  However, the deployed object does not show up in the list of available WD objects.  Other WD applications also do not show up in the list if I pick the WD application as a callable object to set up.  My assumption is that if these are not deployed to the portal they will not show up in the list.  Are there settings or some configuration for the portal that will allow WD apps, etc. deployed to other servers to show up in the list as available objects?
    Thanks,
    Cindy

  • Send uploaded file to another server

    i have build a bsp who can i upload 2 files.
    these files are saved in a table with filename, extention and content. now i want to send these informations to a external server.
    i found nothing about this theme...
    have somone a idea?
    thx
    Dogas
    Message was edited by: Chris McDogas

    There is a coding example in this weblog of using the HTTP Client Functionality:
    /people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap
    However I think that only gets you part of the way there.  I'm still now sure exactly what mechanism you will use to upload the file.  That is why I asked can you perform the action from a PC.  I was trying to figure out if there is a webpage on this external server that has a UI for uploading the file. Just making an HTTP connection isn't going to magically transport your file up to this external server.

  • Sending an object from client to server always on button press

    What I need is to send an object from client to server but I need to make server wait until another object is sent. What I have is the JFrame where you put the wanted name and surname, then you create a User object with these details and on button press you send this object to the server. I just can't hold the connection because when I send the first object, server doesn't wait for another button click and throws EOFexception. Creating the while loop isn't helpfull as well because it keeps sending the same object again and again. The code is here
    public class ClientFrame extends JFrame {
        private JButton btnSend;
        private JTextField txfName;
        private JTextField txfSurname;
        public ClientFrame() {
            this.setTitle(".. ");
            Container con = this.getContentPane();
            con.setLayout(new BorderLayout());
            txfName = new JTextField("name");
            txfSurname = new JTextField("surname");
            btnSend = new JButton(new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    SSLSocketFactory f =
                            (SSLSocketFactory) SSLSocketFactory.getDefault();
                    try {
                        SSLSocket c =
                                (SSLSocket) f.createSocket("localhost", 8888);
                        c.startHandshake();
                        OutputStream os = c.getOutputStream();
                        ObjectOutputStream oos = new ObjectOutputStream(os);
                        InputStream is = c.getInputStream();
                        ObjectInputStream ois = new ObjectInputStream(is);
                        boolean done = false;
                        while (!done) {
                            String first = txfName.getText();
                            String last = txfSurname.getText();
                            User u = new User();
                            u.setFirstName(first);
                            u.setLastName(last);
                            oos.reset();
                            oos.writeObject(u);
                            String str = (String) ois.readObject();
                            if (str.equals("rcvdOK")) {
                                System.out.println("received on the server side");
                            } else if (str.equals("ERROR")) {
                                System.out.println("ERROR");
                        //oos.writeObject(confirmString);
                        oos.close();
                        os.close();
                        c.close();
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(ClientFrame.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        System.err.println(ex.toString());
            btnSend.setText("send object");
            con.add(btnSend, BorderLayout.PAGE_START);
            con.add(txfName, BorderLayout.CENTER);
            con.add(txfSurname, BorderLayout.PAGE_END);
            this.pack();
            setSize(200, 150);
            setVisible(true);
    public class TestServer {
        public static void main(String[] args) {
            try {
                KeyStore ks = KeyStore.getInstance("JKS");
                ks.load(new FileInputStream(ksName), ksPass);
                KeyManagerFactory kmf =
                        KeyManagerFactory.getInstance("SunX509");
                kmf.init(ks, ctPass);
                SSLContext sc = SSLContext.getInstance("TLS");
                sc.init(kmf.getKeyManagers(), null, null);
                SSLServerSocketFactory ssf = sc.getServerSocketFactory();
                SSLServerSocket s = (SSLServerSocket) ssf.createServerSocket(8888);
                printServerSocketInfo(s);
                SSLSocket c = (SSLSocket) s.accept();
                InputStream is = c.getInputStream();
                ObjectInputStream ois = new ObjectInputStream(is);
                OutputStream os = c.getOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(os);
                boolean done = false;
                User u;
                  while(!done){
                    u = (User) ois.readObject();
                    String confirmString = "rcvdOK";
                    String errorString = "ERROR";
                    if (u != null) {
                        System.out.println(u.getFirstName() + " " + u.getLastName());
                        oos.writeObject(confirmString);
                    } else if (u == null) {
                        oos.writeObject(errorString);
                is.close();
                s.close();
                c.close();
            } catch (Exception e) {
                    System.err.println(e.toString());
    }Thanks for any help, btw this doesnt need to be via ssl, the problem would be the same using only http. Please anyone help me:)
    Edited by: Vencicek on 7.5.2012 2:19
    Edited by: EJP on 7/05/2012 19:53
    Edited by: Vencicek on 7.5.2012 3:36

    Current code fails because it's sending still the same entity again(using while loop)No it's not. You are creating a new User object every time around the loop.
    which makes the system freezeWhich means that you are executing network code in the event thread. Don't do that, use a separate thread. At the moment you're doing all that sending inside the constructor for ClientFrame which is an even worse idea: you can never get out of there to the rest of your client program. This is a program design problem, not a networking problem.
    and doesn't allow me to set new parameters of the new entityI do not understand.
    I need to find a way to keep Server running even when the client doesn't send any data and wait until the client doesnt press the send button again to read a new object.That's exactly what happens. readObject() blocks until data is received.

  • Applet/Servlet/serialized objects/HTTPS/Intranet problem

    We've got a Webapplication with[b] applets on the client and servlets on the server side.The Applet send serialized Objects over HTTPS (SSL) to the servlet. The servlet does some business logic and send the answer the same way back.
    In all our tests and in the most cases the application works without any problems.
    But in some Intranet environments we get occasionally (not definitely reproducable) the following error:
    <Oct 1, 2004 8:26:00 AM>  [AnmeldenService] {Service-readThreadAks-AnmeldenServiceThread}
    java.io.EOFException: Expecting code
    at java.io.ObjectInputStream.peekCode(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    at com.dsh.egb.aks.betrieb.rclt.service.ServiceThread$2.run(ServiceThread.java:222)
    at java.lang.Thread.run(Unknown Source)Has anybody an idea how to further analyse this problem?
    Thanks,
    Mark
    We use JRE/JDK 1.3.1_10.

    Here some more Information about our environment:
    Server: Apache 1.3.26 / Openssl 0.9.6d /WinNT 4.0 /HTTP Redirect to Tomcat 4.0.1/ JDK1.3.1_10/ WinNT 4.0
    Client: Plugin 1.3.1_10/Internet Explorer 6.0 (SSL)/Win NT 4.0

  • How to transport objects from one server to another server?

    How to transport objects from one server to another server.ie..from development to testing sewrver....

    Hi Manoj,
    Check these links
    http://help.sap.com/saphelp_nw2004s/helpdata/en/93/a3a74046033913e10000000a155106/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/a8/5e56006c17e748a68bb3843ed5aab8/frameset.htm
    Transporting Objects IR ID using CMS
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f85ff411-0d01-0010-0096-ba14e5db6306
    http://help.sap.com/saphelp_nw2004s/helpdata/en/e1/69a740aa053a13e10000000a155106/frameset.htm
    You can choose either File transfer methor or CMS. File transfer method is the simplest.
    Sachin

  • How can you move the objects from one server to another?

    how can you move the objects from one server to another?

    Hi,
    Collecting objects for Transporting
    1. rsa1->transport connection
    2. left panel choose 'object type', middle panel choose 'infocube' and 'select objects'
    3. then choose your infocube and 'transfer'
    4. will go to right panel, choose collection mode 'manual' and grouping only 'necessary objects'
    5. after objects collection finished, create request
    6. If they are $TMP, then change the package.
    7. When you click the Save on the change package, it will prompt for transport. Here you can provide an existing open transport request number, or if you like here itself you can create a new one.
    8. You can check the request in SE09 to confirm.
    Releasing Transport Request  
    Lets say you are transporting from BWD to BWQ
    Step 1: In BWD go to TCode SE10
    Step 2: Find the request and release it (Truck Icon or option can be found by right click on request #)
    Note: First release the child request and then the parent request
    Steps below are to import transport (generally done by basis )
    Step 1: In BWQ go to Tcode STMS
    Step 2: Click on Import queue button
    Step 3: Double Click on the line which says BWQ (or the system into which transport has to be imported)
    Step 4: Click on refresh button
    Step 5: High light the trasnport request and import it (using the truck icon)
    Transport
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/1d733b73a8f706e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/0b/5ee7377a98c17fe10000009b38f842/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/224381ad-0701-0010-dcb5-d74236082bff
    Hope this helps.
    thanks,
    JituK

  • Transportation ( how to transport objects from one server to another)

    Hi BW guru's
    Please tell me the steps to transport objects from one server to another server.

    Follow the steps.
    1. RSA1 > Transport connection
    2. In the right window there is a catagory "all object according to type"
    3. Select required object you want to transport.
    4. Expand that object , there is select object, double click on this you will get the number of objects, select yours one.
    5. Continue.
    6. Go with the selection, select all your required objects you want to transport.
    7. There is icon Transport Object (Truck Symbol).
    8. Click that, it will creat one request, note it down this request.
    9. Go to Transport Organiser (T.code SE01).
    10. in the display tab, enter the Request, then go with display.
    11. Check your transport request whether contains the required objects or not, if not go with edit, if yes "Release" that request.
    Thats it, your cordinator will move this request to Quality or Production.
    Hope its helps.
    Regards

  • Sending object between client server with some class without serializable

    Hi friend,
    I need to send the object from server to client via ObjectInputStream and ObjectOutputStream, however, in these objects, some are implements by others, no source code provided, which haven't implement serizlizable, so does anyone can tell me what I can do?
    Thanks your concern.
    Cheers,
    Alva

    Anyone can help? It is urgent!
    Thanks,
    Alva

Maybe you are looking for

  • Nulls in Rowsets

    The issue with dataTables is well known - they currently don't handle fields with nulls in them gracefully. But it also appears there is an issue with standard rowSets - I have a panelGrid of textFields, and if one of my columns in the rowSet is null

  • Outlook 2011 for Mac Sync

    I purchased a Q10 several weeks ago and still cannot get it to sync with my Outlook 2011 for Mac.  I have installed the latest update to Blackberry Link but as was the case when I first tried the calendar and contact sync section is greyed out.  I ca

  • To update the po line item data into sap thru bdc

    Hi Experts, My requirement is to create a bdc program .  get the po line item data from the file and will update in sap thru bdc .so please help on source code how to create . Thanks advance, Prashanth p.

  • Remove / unload external swf file(s) from the main flash file and load a new swf file and garbage collection from memory.

    I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the

  • BPM 11g integration with UCM11g using Java Enbedded acitivity

    Hi Friends, Can anyone throw some idea how to integration with BPM11g and UCM11g We need to have a java code using Java Enbedded acitivity. 1) How to Connect to UCM 11g using java code any sample Java Embedded Code( we are connecting through RIDC) 2)