J Virumbi

Greenhorn
+ Follow
since Nov 15, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by J Virumbi

Look at ur this line:

new Test4().tf.setText("HelloWorld");

The "new" keyword will be creating a new Instance of Test4 class for every click on the button. Offcourse you can not see the new GUIs bcoz u are not calling builfGUI method.

If U want set a "hello World" text in the textfield for each button click, U have to do it on the existing instance of Test4 which has built ur GUI.

I have never coded in AWT. I can solve the problem but It may not be the right practise.

Check the books coz u missed the basics.
19 years ago
Hi,
1) I tried both GET as well as POST. It did not work.
2) is it possible for a webserver to know wheather a http request received by it has been made from a browser or from an application ?
3) is that a right piece of code for what I am looking for ?
Thanks
Hi all,
I want to call some web URL from java application.
When I use "HttpUrlConnection", I get an "OK" responce message. But the target webserver is NOT processing the request appropriately. (I can not check the code in the target app)
I mean,
If u use the same URL straight in the browser, It is working fine as expected.
is there any header prop, etc... or anything else need to be set in for the HttpUrlConnection class.
(Additional question:How to provide the proxy user_name and pass_word for the UrlConn ??)
Fowwing the URL and the code
++++++++++++++++++++++++++++++
import java.net.*;
import java.io.*;
public class HttpTest
{
public static void main (String[] s)
{
try{
URL url = new URL("http://www.m1.com.sg/msgcenter/handphone/msg.cgi?type=handphone&pno=12345678&msg=testmsg");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();

connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.usingProxy();
java.util.Properties props = System.getProperties();
props.put("http.useProxy", "true");
props.put("http.proxyHost", "33.33.3.3");
props.put("http.proxyPort", "8080");
connection.connect();

System.out.println("\n Responce Msg: "+connection.getResponseMessage() );

System.out.println("\n M1 Server Date: "+connection.getDate());
System.out.println("\n Local Sys Date: "+System.currentTimeMillis());

connection.disconnect();

}catch(Exception e){e.printStackTrace();}
}
}