Solved

Sending Requests from an Java Standalone Application

Posted on 2002-05-31
3
176 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

943 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

6 Experts available now in Live!

Get 1:1 Help Now