2010-11-26 20 views
0

私はおかげで.......strutsのjavaアクションからurlを呼び出す方法は?

public void sendsms() throws IOException 
    { 
    URL sms = new URL("http://india.timessms.com/http-  api/receiverall.asp?username=way2sijo&password=*******i&sender=Demo&cdmasender=9930065297&to=919930065297&message=Hello"); 
    BufferedReader in = new BufferedReader(
    new InputStreamReader(sms.openStream())); 

    String inputLine; 

    while ((inputLine = in.readLine()) != null) 
     System.out.println(inputLine); 

    in.close(); 
    } 

しかし、例外

in thread "main" java.net.SocketException: Network is unreachable: connect 
     at java.net.PlainSocketImpl.socketConnect(Native Method) 
     at java.net.PlainSocketImpl.doConnect(Unknown Source) 
     at java.net.PlainSocketImpl.connectToAddress(Unknown Source) 
     at java.net.PlainSocketImpl.connect(Unknown Source) 
     at java.net.SocksSocketImpl.connect(Unknown Source) 
     at java.net.Socket.connect(Unknown Source) 
     at java.net.Socket.connect(Unknown Source) 
     at sun.net.NetworkClient.doConnect(Unknown Source) 
     at sun.net.www.http.HttpClient.openServer(Unknown Source) 
     at sun.net.www.http.HttpClient.openServer(Unknown Source) 
     at sun.net.www.http.HttpClient.<init>(Unknown Source) 
     at sun.net.www.http.HttpClient.New(Unknown Source) 
     at sun.net.www.http.HttpClient.New(Unknown Source) 
     at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) 
     at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) 
     at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) 
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
     at java.net.URL.openStream(Unknown Source) 

どのように私はこのproblamを解決することができ、次のこの1回の上映を実行している間に次のようにURLからSMSを送信しようとしています事前に.......

答えて

1

あなたはapache httpクライアントライブラリを見て、それを使ってget requestを作るのがよいでしょう。

関連する問題