Passing an Object to a Servlet from a standalone Java code

Discussions

Web tier: servlets, JSP, Web frameworks: Passing an Object to a Servlet from a standalone Java code

  1. Hi,
      Can I pass an Object to a Servlet from a standalone Java code?
    I have explored the possibiity of passing an object using HttpURLConnection Class, but this technique doesn't seem to work(Please correct me if I am wrong).

    My scenario is like this :
    I have an Servlet on my appserver. And my standalone java code has to pass Objects to the aforementioned Servlet. How can I do this?
    It would be really nice if I can get some sample code.

    Does any one has a workaround?

    Thanks and regards,
    Shyam Natarajan
  2. What do you mean by 'standalone Java code'? Is it in a separate JVM? If so, you can use RMI or to spare the trouble just pass parameters of your object through simple HTTP and create its copy on the appserver. Could make your system clearer?
  3. Of course you can. You can use http, your own socket and rmi.
    I prefer to using http to transfer the object. It is classic, nothing new.