Solved

Sending Requests from an Java Standalone Application

Posted on 2002-05-31
3
175 Views
Last Modified: 2012-05-04
hi

I have created a standalone application using java AWT.
From my java application i need to send a request to the server and getback the response from the server which will should send some content back.

The most important thing is
How to send a request from my application ?

Is there any solution, if anybody have tried do help me.

Thanks in advance.
0
Comment
Question by:ayeshanasreen
  • 2
3 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 7046691
 If you would like to use TCP/IP then open a socket connection to the server, send the data to the server and then read the response back.

  Hope it helps.
0
 
LVL 35

Expert Comment

by:girionis
ID: 7046693
 ...for more info on sockets/connections over TCP/IP and UDP/IP take a lookhere:

http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html

  Hope it helps.
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 200 total points
ID: 7046737
if you have to send a request to http server - you can use URLConnection:

 
java.net.URL url = new java.net.URL("http://www.yahoo.com"); // the requested URL
java.net.URLConnection conn = url.openConnection();
//conn.setDoInput(true);
java.io.InputStream in = conn.getInputStream();
// then use in.read() methods to get the content of the response
 
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now