aspose file tools*
The moose likes Servlets and the fly likes HTTP Server / Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Server / Client" Watch "HTTP Server / Client" New topic
Author

HTTP Server / Client

vinay kharad
Greenhorn

Joined: Apr 20, 2006
Posts: 1
Dear all.

I need to write one HTTP socket Server / client programme where in i will receive a HTTP request like ( http://sms.example.in/receivesms/Message.aspx?usr=abc&pass=xyz&msisdn=919820667597&sid=SMS&msg=test from swappy&mt=0 ) process the request and again send a HTTP request to this gateway using the HTTP Protocol Get Method like ( ttp://sms.startcorp.in/sendsms/Message.aspx?usr=abc&pass=xyz&msisdn=919820667597&sid=SMS&msg=test from swappy&mt=0 )

I need to know can i do this by jst writting simple HTTP Server / Client routine by using JAva.net package. Or do i essentially need to use any Web Server (Tomcat) to receive the request from gateway and send request. here it has to be both Server and Client.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
Welcome to JavaRanch.

While it is possible to write the server-cum-client just using the java.net package, why reinvent the wheel? It would be much easier to use Tomcat (or some other servlet engine) as the server, and have that make an HTTP request using the java.net package in turn.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Strictly you don't need to use a ready made HTTP server (I have written a few special-purpose ones in the past). You can find example server source code pretty easily

Making an HTTP request as a client might even be more difficult. Personally I often use HTTPUnit for this, mainly because I'm familiar with it.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
I agree with Frank. Writing is simple HTTP request processor is quite easy. Sun supplied a good one in one of internal undocumented packages, but for some reason withdrew it recently. Creation of HTTP client is a bit more work, but httpurlconnection is working in most cases. Writing your own server can be even preferable because you can control keep-alive in better your app specific way.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
This advice all sounds right on. If you're interested in writing your own HTTP server, see FitNesse.org for another neat example. The code is about 10% as big as the HTTP stuff I wrote for myself. Pretty slick.

Some of the code I read to learn how to do this was peppered with comments like "obsolete version of obscure browser xyz sends an extra newline here" which made it clear it would not be easy to write a robust HTTP server to expose to the world at large. My own is supported only for captive users in my company on standard IE6 configurations and a few of us using FireFox.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP Server / Client