Overview:

    * This Java sample code will allow a user to send an sms message from a cell phone to the iSMS device and the iSMS device will send it to the Apache Tomcat Web Server via IP. The Apache Tomcat Web Server will then call the Java servlet file to write the incoming sms message to a text file on the local hard drive.

Prerequisite:

    * Download and Install JDK and JRE 6 update 21 at http://java.sun.com/javase/downloads/index.jsp
    * Download and Install Apache Tomcat 6.0 Web Server at http://tomcat.apache.org/
    * Download the Java sample source code iSMSSendAndReceive-Java.zip here

Setting up Tomcat to run servlet and jsp file:

a. Go to directory:

C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib

and do a copy – servlet-api.jar and then pasted it in:

C:\Program Files\Java\jdk1.6.0_17\jre\lib\ext

Note:

Replace the path above to your path.

Modify the web.xml:

a. Find the first section below and uncommented it:

<!--
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
-->

b. Find the second section below and uncommented it:

<!--
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
-->

c. Save it.

Modify the context.xml:

a. Find the line:

<Context>

b. Modify it, so it looks like below:

<Context reloadable="true" privileged="true">

c. Save it and restart the Web Server.

Modify and Compile Java source code:

a. Put the file named: Send.jsp under the webapps/ROOT folder of your TomCat6.0 folder.

b. Create a folder named: classes under your webapps/ROOT/WEB-INF folder.

c. Put both Response and Send folders under this webapps/ROOT/WEB-INF/classes/.

d. Go to the command prompt and cd into the folder Response and compile the source code by typing:

javac *.java

iSMS device setup:

    * Go to your SMS finder -> SMS Service -> SMS API:
    * HTTP API status: Checked.
    * HTTP port: 81.
    * Click on Save Button.
    * None polling Receive API status: Checked.
    * Protocol: HTTP.
    * Click on Save Button.
    * Server: xxx.xxx.xxx.xxx (Enter your Web server IP address here)
    * Port: 80.
    * Click on Save Button.
    * Server Default Page: servlet/Response.ResponseServlet
    * Click on Save Button.

Notes:

    * If you send an sms message from your cell phone to the iSMS device, the iSMS device will send that sms message to the Tomcat Web Server and the Tomcat Web Server will call the ResponseServlet.class to write the message to a text file named – receive.log.
    * Send.jsp is an html form that allows you to send the sms message from your web browser.
    * You must also modify the SendServlet.java to point to your iSMS device before you can send the sms message to iSMS device via Web browser.

Modify and Compiling the SendServlet.java:

a. Go to folder Send, highlight the SendServlet.java and right click -> Select Open. This will load the SendServlet.java file into either NotePad or Word. Find the line below and modify it so that it will points at your iSMS device and change the user name and password to match yours.

response.sendRedirect("http://172.17.29.233:81/sendmsg?user=admin&passwd=admin
&cat=1&to=" + recipient + "&text=" + message);

b. Save it.

c. Go to the command prompt and cd into the folder Send and compile the source code by typing:

javac *.java

Now, you should be able to send a SMS message to your iSMS device through the Web browser. Bring up your web browser (IE or FireFox) and go to http://localhost/Send.jsp. You will get a Send Message Form.