aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Simple Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Simple Problem" Watch "Simple Problem" New topic
Author

Simple Problem

Raja Islam
Ranch Hand

Joined: Dec 07, 2001
Posts: 74
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/ms/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

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);}
}
}
Raja Islam
Ranch Hand

Joined: Dec 07, 2001
Posts: 74
Sorry
The value of form action is
action="http://www.mobilinksms.com/sms/smsform.asp
Raja Islam
Ranch Hand

Joined: Dec 07, 2001
Posts: 74
I need quick reply
pls help me
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Simple Problem