• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple Problem

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
i make a simple servlet which send msg to www.SmsSite/SmsScript.asp it connects but not send msg.i am using this servlet to use in my computer for getting simple parameters and it is working fine. i think there is no problem with parameters values of mine and SmsSite cause i send msg using simple form and it is working fine.pls help me.
it is working fine

<form method=POST action="http://www.mobilinksms.com/sms/smsform.asp" name="SMS">
<input type="hidden" name="email" value="SMS-Daemon@vxt.com">
<input type="hidden" name="recipient" value="sms@vxt.com">
<TEXTAREA NAME=MESSAGE ROWS=5 COLS=35></TEXTAREA>
<input type="text" name="PHONE" size="10" maxlength="8">
<INPUT TABINDEX="10" MAXLENGTH=3 SIZE=2 VALUE="150" NAME="smsLEFT" readOnly>
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Send" >
</form>
There is some problem in it.it connects to website but sending no msg.

import java.io.*;
import java.util.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Sms extends HttpServlet implements Runnable {
Thread thread;
URL url;
public void init() {
try {
System.out.println("Init");
thread=new Thread(this);
}
catch(Exception e){System.out.println("Error: "+e);}
}
public void doGet(HttpServletRequest req,HttpServletResponse res) {
thread.start();
}
public void run() {
try {
while(true) {
System.out.println("Sending Msg At : "+new Date());
sendSms();
thread.sleep(60*500);
}
}
catch(InterruptedException ie) {System.out.println("InterruptedException :"+ie);}
}
private void sendSms() {
try {
System.out.println("Connecting.....");
URL cellUrl = new URL("http://www.mobilinksms.com/sms/smsform.asp");
HttpURLConnection con = (HttpURLConnection) cellUrl.openConnection();
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
String x ="email=SMS-Daemon@vxt.com&recipient=sms@vxt.com&MESSAGE=yahoo&PHONE=2138816&smsLEFT=150&SUBMIT=Send";
con.setRequestProperty("CONTENT_LENGTH", "" + x.length());
OutputStream os = con.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
osw.write(x);
osw.flush();
osw.close();
InputStream is = con.getInputStream();
System.out.println("Msg Has Been Sent");
}
catch(Exception ie) {System.out.println("InterruptedException :"+ie);}
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic