Push Registry : MIDlet  activated by servlet ?

hello, i have been trying to figure this out for days now could someone please help. I am trying to get the MIDlet to by activated by a Servlet which resides on a apache webserver , is this possible?
how do you go about in getting the MIDlet to register a connection which waits for some activity sent via HTTP? do you register a socket to listen on a port on the device and get the servlet to send data to that port via HTTP?(if so how is this done?)
Basically all i am trying to do is get a servlet to send data to the midlet. The MIDlet is installed from the webserver with ease, i want the midlet to wait till the server decides to send some data. the servlet will activate the midlet (this is the problem) , so then the midlet will open the http connection to the servlet.
Please ask if the question needs clarifying, I would be very thankful for any advice provided.
cheers
Max

thanks for info
i have been trying for a while now and cant seem to get this working what i have got is a MIDlet that listens on port 90 of a socket connection. i am trying to create a Servlet that sends data onto port 90 so the midlet can be activated via the push registry. i am having the trouble with the servlet(which i cant get working, i assume that the code is wrong), i cant seem to get a socket connection working, i have tried to open a socket connection but have had no luck.
i have posted some code, the MIDlet is there and so is my attempt at a servlet.
what i want to do is get the servlet sending the midlet data on a specified port
and the midlet recieveing that data and displaying it on the mobile emulator
(so far all the MIDlet code does is listen for some activaty on port 90 and then send some data to the browser on the following url : http://localhost:90/)
if anyone can get this problem on this example code i am testing on, fixed it would be much appreciated!!
Thanks
Max
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.pki.*;
public class PatchyMIDlet
    extends MIDlet
    implements CommandListener, Runnable {
  private Display mDisplay;
  private Form mForm;
  private ServerSocketConnection mServerSocketConnection;
  private boolean mTrucking = true;
  public void startApp() {
    mDisplay = Display.getDisplay(this);
    if (mForm == null) {
      mForm = new Form("PatchyMIDlet");
      mForm.addCommand(new Command("Exit", Command.EXIT, 0));
      mForm.setCommandListener(this);
    Thread t = new Thread(this);
    t.start();
    mDisplay.setCurrent(mForm);
  public void pauseApp() {}
  public void destroyApp(boolean unconditional) { shutdown(); }
  private void log(String text) { log(null, text); }
  private void log(String label, String text) {
    StringItem si = new StringItem(label, text);
    si.setLayout(Item.LAYOUT_NEWLINE_AFTER);
    mForm.append(si);
  private void shutdown() {
    mTrucking = false;
    try { mServerSocketConnection.close(); }
    catch (IOException ioe) {}
  public void commandAction(Command c, Displayable s) {
    if (c.getCommandType() == Command.EXIT) {
      shutdown();
      notifyDestroyed();
  public void run() {
    try {
      mServerSocketConnection =
(ServerSocketConnection)Connector.open("socket://:90");
      log("Startup complete.");
      SocketConnection sc = null;
      while (mTrucking) {sc =
(SocketConnection)mServerSocketConnection.acceptAndOpen();
        log("client: ", sc.getAddress());
        // Strictly speaking, each client connection
        // should be handled in its own thread. For
        // simplicity, this implementation handles
        // client connections inline.
        Reader in = new InputStreamReader(sc.openInputStream());
        String line;
        while ((line = readLine(in)) != null) ;
        // Ignoring the request, send a response.
        PrintStream out = new PrintStream(sc.openOutputStream());
        out.print("HTTP/1.1 200 OK\r\n\r\n");
        out.print(getMessage());
        out.close();
        in.close();
        sc.close();
    catch (Exception e) {
      log("exception: ", e.toString());
  private String readLine(Reader in) throws IOException {
    // This is not efficient.
    StringBuffer line = new StringBuffer();
    int i;
    while ((i = in.read()) != -1) {
      char c = (char)i;
      if (c == '\n') break;
      if (c == '\r') ;
      else line.append(c);
    if (line.length() == 0) return null;
    return line.toString();
  private java.util.Random mRandom = new java.util.Random();
  private String getMessage() {
    int i = Math.abs(mRandom.nextInt()) % 5;
    String s = null;
    switch (i) {
      case 0: s = "Above all the others we'll fly"; break;
      case 1: s = "There is no reason to hide"; break;
      case 2: s = "I dreamed about Ray Charles last night"; break;
      case 3: s = "Someone keeps moving my chair"; break;
      case 4: s = "Joseph's face was black as night"; break;
      default: break;
    return s;
}the Servlet code, which i cant get working:
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.net.*;
import java.lang.*;
public class Servlet extends HttpServlet {
  private int mCount;
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
    String message = "Hits: " + ++mCount;
    String connectString = "socket://:90";
    SocketConnection sc = null;
    DataOutputStream dos = null;
      // open a socket connection with the remote server
      sc = (SocketConnection) Connector.open(connectString);
// an OutputStream is created on top of the
      // OutputConnection object for write operations
      dos = sc.openDataOutputStream();
// perform write operations
      dos.writeChars("hello");
  }

Similar Messages

  • Push Registry is not starting the MIDLET automatically

    I am not being able to start my MIDLET using the push registry mechanism. I am using the netbeans emuluator to execute the program.
    In the startApp of my application I have
         connections = PushRegistry.listConnections(false);
    and whenever a connection comes it starts a new thread. My Client keeps sending SMS requests but the server midlet in which the
    push registry is initiated does not start.
    In the application Descriptor I have added the following
    MIDLET class : Server.SMSReceive_S
    Sender IP : *
    Connection String : sms://:5000
    and in the API permissions I have added the following API permissions
    javax.microedition.io.PushRegistry, javax.wireless.messaging.sms.receive, javax.wireless.messaging.sms.send
    I have even tried to start the MIDLET dynamically by calling
         PushRegistry.registerConnection(smsConnection,this.getClass().getName(),filterName);
    but that too doesnt work?
    So what am I doing wrong in starting the MIDLET automatically using push registry?

    Hi, Malte
    I have given individual nodes address in db2nodes.cfg,  as per your instruction I have run the db2 list database directory I have got the following output
    System Database Directory
    Number of entries in the directory = 1
    atabase 1 entry:
    Database alias                       = SOP
    Database name                        = SOP
    Local database directory             = /db2/SOP
    Database release level               = b.00
    Comment                              = SAP database SOP
    Directory entry type                 = Indirect
    Catalog database partition number    = 0
    Alternate server hostname            =
    Alternate server port number         =
    => db2 list node directory
    => SQL1027N  The node directory cannot be found
    Regards

  • Sign midlet and push registry

    Hello people ,
    Am wandering if i signed my midlet will the permission for push registry be "always yes", i mean no security messages will be shown to the user?
    thanx in advance

    Find your answer here :
    http://discussion.forum.nokia.com/forum/showthread.php?p=184664#poststop
    SD

  • Push Registry - "ping ponging" midlets

    i am currently trying to build test apps that utilizes push registry using sockets
    basically, i have 2 midlets, let's name them midlet1 and midlet2
    1. i launch midlet1
    2. then i exit midlet1
    3. exiting midlet1 triggers the push for launching midlet2
    4. midlet2 launches by itself
    5. i then exit midlet2
    6. similarly, exiting midlet2 triggers the push for launching midlet1
    7. midlet1 launches by itself
    8. i tried repeating everything from step 1, but it doesnt work..
    anyone familiar with this situation?
    i tried closing the socket connection during destroyApp() and of course the threads are stopped as well, but obviously they didn't worked for me..
    Edited by: novarian_brian.balote on Sep 26, 2008 1:22 AM
    Edited by: novarian_brian.balote on Sep 26, 2008 1:23 AM
    Edited by: novarian_brian.balote on Sep 26, 2008 1:24 AM

    sure, so yes its only on midp2, the JAD stuff you're talking about is only for the pushregistry in midp2.
    how it works? you tell the AMS (application management system) on the phone that when it installs MyMIDlet it should attach it to some port (say... 5444 for example).
    cool so now its installed.
    now when your phone gets an SMS nothing happens... UNLESS that SMS is directed at port 5444. At that point, the AMS will invoke MyMIDlet.
    but ya, you need MIDP2.0

  • Signed midlet with push registry

    hi,
    one midlet application was trused (ex:- signed from verisign)
    application code using alaram based push registry
    so when alaram puch activate then will it ask any alert question ? for trusted midlet (alert is like myMidlet have need to open?)
    i was cheaked for untrusted midlet so their asking the alert question
    (i forget the alert matter exatly)
    if it is trusted then what happen?
    can any one help me who ever experiance with this
    thanx in adv

    plz help me

  • Sockets and push registry

    Hello,
    I want to get a socket connection between a MIDlet and servlet whats the best was to do this? so i can send information back and forth
    ( the MIDlet needs to be activated also by the socket connection from the Servlet)
    I have read the article on push registry but still am a bit in the dark.
    Thanks.

    Find your answer here :
    http://discussion.forum.nokia.com/forum/showthread.php?p=184664#poststop
    SD

  • Whats the logic in push registry???

    hi,
    was jus doin this push registry thing. in short Midlet registers itself to AMS then whenever some event occurs such as time or something happnes at specific port then midlet is started....
    but in example application i saw and tried to make i have to keep my listner midlet running so that it can listen to push events. now wheres that AMS working.....????
    i thought push registry was some sort of demon working beind the scene and gets activated only when some event occurs. infect i should not call it deamon according to book it is dead and only activates when called by AMS due to some registred event....
    AAqib

    I don't understand the question. The Docs are pretty specific here...
    "When the application is not running, the application management software(AMS) listens for inbound notification requests. When a notification arrives for a registered MIDlet, the AMS will start the MIDlet via the normal invocation of MIDlet.startApp method."
    Like the docs say, your applet will be started when the desired even occurs. It does not need to be running to listen for events. This really is how it works. If you use the 'Alarm' functionality, your midlet will be started after a set amount of time. The Javadoc's on the PushRegistry even have example code.
    Are you having trouble with something specific?

  • Push Registry headless app

    The [push registry page|http://developers.sun.com/mobility/midp/articles/pushreg/] mentions:
    User interface and headless applications - Even though it's possible to create a push-activated MIDlet that exposes no user interface, doing so may confuse the user - at a minimum, provide a simple screen that tells the user what your application is attempting to do.
    I would like to create a headless application... well I have a front end, but I would like push-woken portion to have no UI. If I supply no Displayable, the Java splash is shown until notifyDestroyed().
    I'm sure this is possible on platforms that allow multiprocessing such as WinMo, Ericsson, and Android, but I'm hoping there's some native Java way to prevent any UI from being displayed (splash screen included).

    Hi, I think that it's fully possible only in MIDP-3.0.
    Anyway, try to play with the MIDlet.notifyPaused method(). However I've never tried it yet. You must check the behaviour on particular handset because it may not be the same on all handsets.
    Rada

  • Help in Push Registry On S40

    i have a problem in push registry on s40
    it throw the exception
    ClassNotFoundException : Midlet Not Found
    i try the Same Code In S60 it run Well
    The Code::::
    private void Test() {
    try {
    System.out.println
    ("Befffforrrrrrrrrrrrr");
    long x= DF.getDate().getTime();
    prevalarm = PushRegistry.registerAlarm(this.getClass().getName(),x);
    System.out.println
    ("Afterrrrrrrrrrrrrrrrrrrrrrrrr");
    catch (ConnectionNotFoundException ex) {
    System.out.println("Erorororo 1 :"+ex.getMessage().toString());
    catch (ClassNotFoundException ex) {
    System.out.println("Erorororo 2 :"+ex.getMessage().toString());
    /**************************/The Jad file
    MIDlet-Name: DemoForFun
    MIDlet-Version: 1.8
    MIDlet-Vendor: DemoForFun
    MicroEdition-Profile: MIDP-2.0
    MicroEdition-Configuration: CLDC-1.1
    MIDlet-Jar-URL: DemoForFun.jar
    MIDlet-Jar-Size: 2096
    MIDlet-Permissions: javax.microedition.io.PushRegistry
    MIDlet-1: DemoForFun, , DemoForFun

    S40 Is MIDP 2.0
    The Series 40 Platform 1st Edition supports Java� 2 Platform, Micro Edition (J2ME�) APIs, including Mobile Information Device Profile (MIDP) 1.0, Connected Limited Device Configuration (CLDC) 1.0, and Nokia's user interface APIs
    The Series 40 Platform 2nd Edition added J2ME MIDP 2.0 with Java Specification Requests (JSRs), implementation of Wireless Messaging API (JSR 120), Mobile Media API (JSR 135), and Java APIs for Bluetooth (JSR 82).
    Series 40 Platform 3rd Edition extends J2ME support, implements CLDC 1.1 and MIDP 2.0, and expands on the provision of messaging, mobile media, and Bluetooth technology APIs with support for FileConnection and personal information manager (PIM) (JSR 75), as well as Mobile 3D Graphics (JSR 184).

  • Error on push registry  feature

    Hi admin,
    I am doing, Add MIDP 2.0's push registry feature to device application.
    It workS fine on J2ME wireless toolkit(KTOOLBAR) and i have implemented
    push registry to my project in netbeans. It builds successfully but when
    i run, it producing the following error.
    startApp threw an Exception
    java.lang.IllegalArgumentException: Port format
    at com.sun.midp.io.j2me.sms.Protocol.openPrimInternal(+281)
    at com.sun.midp.io.j2me.sms.Protocol.openPrim(+8)
    at javax.microedition.io.Connector.openPrim(+233)
    at javax.microedition.io.Connector.open(+15)
    at javax.microedition.io.Connector.open(+6)
    at javax.microedition.io.Connector.open(+5)
    at com.sample.MySamplePushRegistry.startApp(+45)
    at javax.microedition.midlet.MIDletProxy.startApp(+7)
    at com.sun.midp.midlet.Scheduler.schedule(+270)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+116)
    Execution completed.
    Wat could be the problem?... pl clarify me...

    hi,
    i have use this code for getting smsport smsPort = getAppProperty("SMS-Port"); and "SMS-Port" this one is initialized in wireless toolkit in user defined settings as 50001.
    if any correction shall i do...

  • Push registry in MIDP, shutdown cellphone effect

    Hello Everyone
    Once a midlet is registered, it will be forever registered? i.e. even if we turn off and on the cell phone the midlet will still listen to the port. If not, how can we persist it over shutdown? If yes, who take care of registring it again when we turn on the phone?
    Thank you
    Roy

    AMS will take care of Push registry regardless of changing the SIM card
    Pravin

  • MIDP2.0 Push Registry Feature in Windows Mobile

    Hi All,
    I have developed the application using the Push Registry feature for MIDP2.0 phones. When i install this application on Windows Mobile, its giving error that Invalid MIDlet. Then i removed the Static Registration from Jad file, and also removed the MessageListener interface from my MIDlet.
    After this process only i am able to install. After installation i have tried to Register the PUSH Registry dynamically from Code, this gives an error that IOException. Is there anyother way to achieve this for Pushing my application automatically on windows mobile when an SMS arrives in Port.? Kindly anyone give me the solution if faced the same problem in Windows Mobile.
    Thanks & Regards
    Ramprasath.P.M

    Hi All,
    Kindly anyone reply to the above question.
    Regards
    Ramprasath.P.M

  • Help needed regarding sms push registry

    HI experts,
    Is it possible to send an sms to a mobile from servlet for invoking push Registry functionality?
    If yes, then tell me how?
    Any one helps me in this regard.
    Thanks and regards,
    raghavendra.M

    Yes.
    How to..
    1. Install a sms gateway and gsm modem.
    2. send sms using the gateway.
    Check out the nowsms gateway or kannel gateway.
    Cheers
    Phani

  • Can I do this with the Push Registry?

    I need to write a midlet that will listen for an incoming message from the comm port on a Motorola i355 iden phone. I don`t care if the midlet is open or closed when the message comes in. Whichever would be fastest would be best. I'm using the phone to process a message and send another message back out through the comm port to a connected machine. I also don't have control over the message that is coming from the machine that the phone will be connected to. This will only be my 2nd J2ME application so I'm very new at this.
    I have seen plenty of examples of using the push registry to do this for a socket and datagram (I don`t even know what a datagram is), but nothing for use with a comm connection. If anyone can steer me in the right direction, it would be greatly appreciated. Thanks.

    Hi
    yes SIR u can
    thx
    souvik

  • Push registry

    Hi,
    I have to make a cell application that stay down until a connection incoming. I have to use push registry. I have to make also a program for pc that work as a "push server": when it has something to send to the cell it sends.
    I find some examples on the net but a lot are for midlet that activate by a sms incoming.
    Someone can explain me what i have to do.
    A simple skeleton or outline for this midlet?
    If I want to start a MIDlet that isn't load I can?

    Yes you can.
    But instead to use the SMS (you have to send it from your server so a little expensive) try to look for socket connections instead. So your application could just register and stay down (the server still needs the target ip if u are going to use sockets)
    The push registry will start your app when data will came (start a thread don't use the listner to do your business!)
    If u get troubles doing this way put your app in background (with symbian you have many options to start an application automatically) and just play a sound when data are being received.

Maybe you are looking for

  • Simple date availability widget in iWeb

    I can integrate my iCal calendar to my iWeb website using the HTML Snippet tool in iWeb but this shows my entire itinerary.  I want a very simple calendar that the visitor to my website can click to see if I am available or booked and that is it, I w

  • Include within an Include not loading?

    On a page I have an Include, within that include is another include. However, the include that is already in an include doesn't appear to load or render. I double checked the file paths and those are correct. Can I have an include within an include?

  • HT1725 itunes says the song is downloaded but, only half of it is there. How do i get the whole song?

    I just tried to download a song I purchased and only half the song is there. when I go back to the itunes store it says the dowload is complete.

  • Access Oracle On Unix using VMS Client

    I am looking for a means to connect a VMS client to an Oracle database that is running on any open OS What is the current version support available? Are there any tools that can be run on a VMS client so as to connect to the Oracle DB. Thanks

  • Still no retina support?

    My Adobe Reader is latest (11.0.02), still no retina support. When it will be supported?