You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ah...@dgcs.gov.om on 2006/05/27 09:38:58 UTC

Advice me

Hello all,

How can i make the Tomcat opens to my servlet once i call it, using this 
call "http://localhost:8080" ???

What i wan to say that i want me own servlet be the default page, and I am 

using apache-tomcat-5.5.17

Thanks

Re: Advice me

Posted by Edoardo Panfili <ed...@aspix.it>.
Ahmed.AlGhafri@dgcs.gov.om 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
-- 
edoardo@aspix.it
AIM: edoardopn


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


Re: Advice me

Posted by Ah...@dgcs.gov.om.
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 ?

Re: Advice me

Posted by Michael Echerer <me...@tngtech.com>.
Ahmed.AlGhafri@dgcs.gov.om wrote:
> Hello all,
> 
> How can i make the Tomcat opens to my servlet once i call it, using this 
> call "http://localhost:8080" ???
Basically this works, if you put a webapp context called "ROOT" into the
webapps directory.
You should have a look at the Tomcat default installation. webapps/ROOT
contains the welcome&docu pages. This should give you a clue how to
configure your own servlets/JSPs.
> 
> What i wan to say that i want me own servlet be the default page, and I am 
You'll need a servlet mapping in your web.xml to do this.
> 
> using apache-tomcat-5.5.17
Might help, too:
http://wiki.apache.org/tomcat/HowTo#head-e82228c43a0ce77f71ebe64fc99ced33c9506ffe

Cheers,
Michael
> 
> Thanks



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