[EMAIL PROTECTED] wrote:
My problem that i want to send a massage to my servlet which is running in Tocat5.5.17 using a client that open a socket connection at 8080 usingTCP/IP connection ? how i can do that ?
I have a group of servelet configured in a Context. To do that you neet to read some documentation Michael said. My Servlet reads the input data from the input stream and the writes the output the the putput stream.

On the client side I have a java application that does simply this:

=======================================================================
private String sendReceive(String servlet, String message) {
  String receivedMesssage;
  String response;
  try {
    URL url = new URL("http", "the.server.name",8080,
        "contextName/" + servlet);
    HttpURLConnection http = (HttpURLConnection) url.openConnection();
    http.setDoOutput(true);
    http.setDoInput(true);

    OutputStream os = http.getOutputStream();
    // if you nedd UTF-8
    OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
    osw.write(message);
    osw.close();
    os.close();

    InputStream in = http.getInputStream();
    // again for UTF-8
    BufferedReader bre = new BufferedReader(
        new InputStreamReader(ingresso, "UTF-8"));    
    // HERE the part of code to read from the stream
    // the result goes in "response"
    bre.close();
    in.close();
    http.disconnect();

  } catch (IOException e) {
    // do something
  }
  return response;
}

=======================================================================

Edoardo
--
[EMAIL PROTECTED]
AIM: edoardopn


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to