#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    8
    Rep Power
    0

    Application -> Servlet Communication


    Hello!!

    Can anybody help me with this? I have an aplication running on a Solaris 7 server (www.sol1.comm). This application needs to send a Vector to a Servlet on another server (www.sol2.comm). I want to use HTTP. Is there somone out ther who has a code example for this?

    Best reguards!
  2. #2
  3. No Profile Picture
    Not A Jedi Yet
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Salt Lake City
    Posts
    8
    Rep Power
    0
    Is the application set up to make http requests? Do you understand how http works? Why do you want to use http? (firewall, etc?)

    What is the "vector" exactly? Is it a Java Vector?

    How are you going to send it in http?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    8
    Rep Power
    0
    The only way to reach this machine is by HTTP.
    Now I know that you can't send Objects over HTTP but variables.
    I just want som code examples on how you connect to a servlet with HTTP and then I can make it on my own.
  6. #4
  7. No Profile Picture
    Not A Jedi Yet
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Salt Lake City
    Posts
    8
    Rep Power
    0
    http is stateless.

    99% of any sample code you see about servlets is "connecting" with http.

    What is your application trying to send? (I don't need specifics, just a general idea)

    What is your app written in?

    To making an http request basically boils down to sending text to a listening port, typically 80. (Tomcat defaults to listening on 8080)

    If I have more info I can try to point you to a solution or at least in the right direction.

    What exactly is the servlet supposed to do when it gets the info?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    8
    Rep Power
    0
    My app is written in Java. I've got three variables (var1=dbname,var2=user,var3=password) that I want to send to a Servlet (Servlet1).

    Servlet1 should (when reseiving the three varables) create a database in mysql.
  10. #6
  11. No Profile Picture
    PHP Coder
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Ontario
    Posts
    66
    Rep Power
    14
    It's as simple as making a client/server dialog. The client asks for the info via short, descriptive commands and the server sends the database info to the client.

    It's almost kind of fun, it's so easy. Just don't forget to put your server socket and every socket it spawns into their own threads, otherwise you will end up with some thread issues and multi-connection problems.
    Click here and wait. It's a kewl effect, trust me.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    8
    Rep Power
    0
    I have solved my problem!! I did it like this by using com.oreilly.servlet.

    Application :

    public static void connectToServlet() {
    try {

    URL url = new URL("http://localhost:8080/servlet/Servlet");

    HttpMessage msg = new HttpMessage(url);

    Properties props = new Properties();

    props.put("database", "Test_database");
    props.put("user", "Test_user");
    props.put("password", "Test_password");

    msg.sendPostMessage(props);


    DataInputStream result = new DataInputStream(new BufferedInputStream(in));


    in.close();

    }
    catch (Exception e) {
    e.printStackTrace();

    }
    }

IMN logo majestic logo threadwatch logo seochat tools logo