Legal | Privacy
Enabling Your Java Application for Wireless Messaging

Enabling Your Java Application for Wireless Messaging

This tutorial describes how to enable a Java application for wireless messaging.

Approximately 25 minutes

This tutorial covers the following topics:

Overview
Prerequisites
Configuring the JDeveloper Wireless Extension (JWE)
Verifying the Installation of the JWE
Creating a Regular J2EE Application
Adding Messaging Capability to the J2EE Application

Place the cursor over this icon to load and view all the screenshots for this tutorial. (Caution: Because this action loads all screenshots simultaneously, response time may be slow depending on your Internet connection.)

Note: Alternatively, you can place the cursor over each individual icon in the following steps to load and view only the screenshot associated with that step.

OracleAS Wireless provides a simple, integrated solution to enhance applications with messaging capabilities. Using the messaging capability of OracleAS Wireless, you can send notification to any kind of device. JDeveloper Wireless Extension (JWE 10g (9.0.5)) enables you to add OracleAS Wireless Messaging to J2EE applications in the JDeveloper IDE (9.0.3.x and above) with the Multi-Channel Messenger Creation Wizard.


In order for this lesson to work successfully, you will need to have performed the following steps:

1.

Installed Oracle JDeveloper 10g

1.

Download jwe.zip from the following location:
http://www.oracle.com/technology/tech/wireless/tools/index.html
This OBE uses JDeveloper (9.0.5) Wireless Extension.

Extract the zip file on your machine.

 

2.

Copy the jwe.jar file to jdev_home\lib\ext folder. For example, if you have installed JDeveloper in E:\jdev10g folder, then copy the jwe.jar file to E:\jdev10g\jdev\lib\ext.

 

3. Restart JDeveloper if you have already started it.

 

1.

Start JDeveloper.

2.

Select Tools from JDeveloper menu and select Preferences.

Move your mouse over this icon to see the image

 

3.

You will see the Preferences dialog. Click Extension Manager.

Move your mouse over this icon to see the image

 

4.

Expand System Extensions.

Move your mouse over this icon to see the image

 

5.

Verify that J2ME Applications, Multi-Channel Applications, and XForms Applications are all selected.

Move your mouse over this icon to see the image

 

You will create a simple J2EE application and enable it for wireless messaging. This application consists of a simple JSP, which prompts for the user's name and displays the name, current date and time. To create this simple J2EE application, perform the following steps:

1.

Select Workspaces in System-Navigator. Right-click and select New Workspace... from the context menu.

Move your mouse over this icon to see the image

 

2.

Change the Workspace Name to MsgApp. Click OK.

Move your mouse over this icon to see the image

 

3.

You will see the Create Project dialog. Enter Msgprj for Project Name and Click OK.

Move your mouse over this icon to see the image

 

4.

Right-click the project in the System-Navigator and select New... from the context menu.

Move your mouse over this icon to see the image

 

5.

Expand Web Tier under categories. Select JavaServer Pages (JSP) and then select JSP Page from Items. Click OK.

Move your mouse over this icon to see the image

 

6.

Enter main.jsp for File Name and click OK. This will create a simple JSP page, which displays today's date when run.

Move your mouse over this icon to see the image

 

7.

You will see the Design view and Source view of main.jsp. You will also see the component palette on the
right side. Close the component palette as shown below.

Move your mouse over this icon to see the image

Click the Source tab. You will see the source code for main.jsp. Modify main.jsp to accept name from the user and display a welcome message. Copy and paste the following code to the code editor of the main.jsp file.
Note: If all the code is copied to a single line, then you can break it into multiple lines for clarity.

<%@ page contentType="text/html;charset=windows-1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>Welcome!!</title>
</head>
<body>
<%
String user = request.getParameter("user");
String currtime = new java.util.Date().toString();
%>
<H3>Welcome
<%= (user==null) ? "" : user %>
</H3>
<P>
<B>The current time is <%= currtime %>.
</B>
</P>

<% if (user == null)
{
%>

<B>Please enter your name:</B>
<form method="get">
<input type="text" name="user" size="15"/>
<input type="submit" value="Submit Name"/>
</form>
<%
}
%>
</body>
</html>

Move your mouse over this icon to see the image

 

8.

Right-click main.jsp. Select Run > in Embedded OC4J Server.

Move your mouse over this icon to see the image

 

9.

You will see the application running on the default browser. Enter your name in the text field and click Submit Name.

Move your mouse over this icon to see the image

You will see the Welcome message.

Move your mouse over this icon to see the image

 

 

To add the messaging capability to the J2EE application, perform the following steps:

1.

Select Msgprj.jpr. Right-click and select New... from the context menu.

Move your mouse over this icon to see the image

 

2.

You will see the New Gallery. Expand Wireless Tier under Categories and select Multi-Channel Applications. Select Multi-Channel Messenger Creation Wizard under Items and click OK.
By using the Multi-Channel Messenger, you will be able to deliver notifications to any device. In this example, we will deliver a voice alert to any phone number entered by the user. Other delivery options include SMS and Email.

Move your mouse over this icon to see the image

 

3.

Note that MultiChannelMessenger.java is automatically added to your project. MultiChannelMessenger.java is a helper class that calls a Web service hosted at messenger.oracle.com to actually deliver the message.

Move your mouse over this icon to see the image

 

4.

Verify if the project includes the OracleAS Wireless SDK library. Right-click the project and select
Project Properties... from the context menu.

Move your mouse over this icon to see the image

 

5.

Select Libraries in the Development node. Note that the OracleAS Wireless SDK library is
inserted into your project. Click OK.

Move your mouse over this icon to see the image

 

6.

To integrate the OracleAS Wireless messaging into your existing application, you must import the MultiChannelMessenger class to your JSP code. Include the following line of code to your main.jsp file:

<%@ page import="oracle.panama.wireless.MultiChannelMessenger" %> 

Move your mouse over this icon to see the image

 

7.

Include the following code in the main.jsp file after the </form> tag.
Note: If all the code is copied to a single line, you can break it into multiple lines for clarity.

<% 
}

else
{
%>
<B>Please enter your phone number including country code (i.e. +18885551212):</B>
<form method="get">
<input type="text" name="phone" size="15" value="+18885551212"/>
<input type="submit" value="Send Message"/>
<input type="hidden" name="user" value="<%=user %>"/>
</form>

<%
}
String phone = request.getParameter("phone");
if (phone != null)
{
MultiChannelMessenger messenger = new MultiChannelMessenger();
messenger.clear();
// set username, password
messenger.setAccount("", "");
messenger.setSender(MultiChannelMessenger.EMAIL, "ENTER YOUR EMAIL ADDRESS");
//messenger.setRecipient(MultiChannelMessenger.VOICE, phone);
messenger.setRecipient(MultiChannelMessenger.SMS, phone);
//messenger.setRecipient(MultiChannelMessenger.EMAIL, "ENTER YOUR EMAIL
// ADDRESS");
//messenger.setProxy("www-proxy.us.oracle.com", 80);

String message = "Hello " + user +
". Thank you for trying Oracle Application Server Wireless!";

messenger.send(message);
%>
<B>Message "<%=message %>" sent to <%= phone %>.
</B>

Move your mouse over this icon to see the image

 

8.

Look for the following code in main.jsp and replace "ENTER YOUR EMAIL ADDRESS" with your e-mail
address:

messenger.setSender(MultiChannelMessenger.EMAIL, "ENTER YOUR EMAIL ADDRESS");

Move your mouse over this icon to see the image

 

9.

Right-click main.jsp. Select Run > in Embedded OC4J Server.

Move your mouse over this icon to see the image

 

10.

You will see the application running on the default browser. Enter your name in the text field and click Submit Name.

Move your mouse over this icon to see the image

 

11.

Enter your phone number and click Send Message.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

 

12.

Optionally try to send a voice mail and e-mail by uncommenting the following lines in main.jsp.
Note: MultiChannelMessenger.java is a helper class, which calls a Web service hosted at messenger.oracle.com to actually deliver the message. You will be able to use this service to deliver a limited number of messages. See http://www.oracle.com/technology/tech/wireless/messaging.htm for details about applying for a messaging trial account.

//messenger.setRecipient(MultiChannelMessenger.VOICE, phone);
//messenger.setRecipient(MultiChannelMessenger.EMAIL, "ENTER YOUR EMAIL
// ADDRESS");

 

In this lesson, you've learned how to:

Configure Java Wireless extension for JDeveloper

Add messaging capability to your J2EE Application

Use MultiChannelMessenger class to send SMS
To ask a question about this OBE tutorial, post a query on the OBE Discussion Forum
To learn more about Wireless and Mobile Services, click here.
To learn how to setup JWE, click here.

 

Place the cursor over this icon to hide all screenshots.

Copyright © 2004 Oracle Corporation. All Rights Reserved.

 

 

 

 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy