Midlet servlet connection

Hi,
I tried almost all the midlets servlet connection examples on various tutorial sites including sun's, they all run perfectly fine on J2ME wireless toolkit emulator but when I download them on Seimens SL45i with WAP connection , J2ME compliant and on O2 XDA pda with GPRS and CrEme virtual java machine and me4se library for MIDlet support its not working. If I connect PDA with PC using MS active sync, the MIDLet is able to connect with servlet or normal web page and retrive data from that perfectly, but when I remove the pda from docking station and run MIDlet, its not able to connect with servlet. Is there something more you have to do to access GPRS or WAP feauture of PDA/mobile phone.
I am using normal HttpConnection to connect with the servlet.
Thanks in advance
Dhiraj

I'm playing with some sockets.
can you please help me?!
J2ME uses only HTTP connections?
and what are the sockets? what is the difference between CLDC socket and J2SE Socket?
is there any other way to communicate with a Servlet?
and very important..
is there a difference if it's using GPRS or 3G?
would the http connection work for all? and just the connection speed would change?
help me!!

Similar Messages

  • Midlet-Servlet interaction

    Hi there,
    Could someone please help with a problem I am having when running a MIDlet on the POSE Emulator.I am trying to run a Midlet which calls a servlet to find the number of hits .I do not have any compilation errors.I am using J2me ToolKit 1.0.4.When I run the Midlet on the Emulator, I am able to reach only upto the point where I can select the program on the POSE Emulator.On selecting the application, I get an error : Uncaught Exception-java.lang.IllegalArgumentException.Please give some suggestions as to the cause of this error.I have been trying the J2me Tutorial Part II-Midlet Servlet Interaction(Sun).
    Thanks in advance

    Hi,
    this exception means that you are trying to pass some variable data to a method and the data is not compatible with those in methods signature, e.g.
    somemethod(java.util.Properties) and you call the method with somemethod(myData) where my data is corrupt or not a descendant of the HashTable or Properties object. If you post the code I will be able to help you better.
    Regs jP

  • Exmpl of Servlet connect with ORacle

    Hi folks,
    Can anyone send me example of Java Servlet connectivity with Oracle.
    i m not able to connect servlet with oracle.
    u guys can reply me on [email protected]
    thanks
    dal hit

    No.
    The code for connecting to Oracle from a Servlet is no different from connecting to Oracle from any other Java application. So tell you what, you show us what you've tried and the error message(s) and we'll help you debug it.
    99.999% of the time it's a failure to put the driver Jar file into the classpath, the specifics of which vary from application server to application server. Which one are you using?
    u guys can reply me on [email protected]
    We can, but we won't. This is not your personal bugfixing service. Pay if you want that kind of help. If you want it for free, do it through the forums or go away.
    Probably you'll never read this response, but that's your problem not mine.

  • Midlet & Servlet(Tomcat) Connection

    I have built up a midlet that need to connect to the servlet which is hosted using Tomcat ...
    When i click the submit button in the mobile emulator ... i received the following message in the console of Java Wireless ToolKit .... What is the problem actually ? .... Can anyone give me some guides ?
    Any Helps will be appreciated
    "<html><head><title>Apache Tomcat/5.0.12 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Servlet RequestServlet is not available</h1><HR size="1" noshade><p><b>type</b> Status report</p><p><b>message</b> <u>Servlet RequestServlet is not available</u></p><p><b>description</b> <u>The requested resource (Servlet RequestServlet is not available) is not available.</u></p><HR size="1" noshade><h3>Apache Tomcat/5.0.12</h3></body></html>"
    The following is my midlet :
    public class SecondMidletServlet extends MIDlet implements CommandListener, Runnable {
    Display display = null;
    List menu = null;
    TextBox input = null;
    String user = null;
    String url = "http://pup.no-ip.net:8001/Servlet/RequestServlet";
    static final Command backCommand = new Command("Back", Command.BACK, 0);
    static final Command submitCommand = new Command("Submit", Command.OK, 2);
    static final Command exitCommand = new Command("Exit", Command.STOP, 3);
         StringBuffer b = new StringBuffer();
    String currentMenu = null;
         Thread thread;
    public SecondMidletServlet() {
    public void startApp() throws MIDletStateChangeException {
    display = Display.getDisplay(this);
    menu = new List("Invoke Servlet", Choice.IMPLICIT);
    menu.append("Add a user", null);
    menu.addCommand(exitCommand);
    menu.setCommandListener(this);
    mainMenu();
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    notifyDestroyed();
    void mainMenu() {
    display.setCurrent(menu);
    public void addName() {
    input = new TextBox("Enter first name:", "", 5, TextField.ANY);
    input.addCommand(submitCommand);
    input.addCommand(backCommand);
    input.setCommandListener(this);
    input.setString("");
    display.setCurrent(input);
    void invokeServlet(String url) throws IOException {
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    //StringBuffer b = new StringBuffer();
    TextBox t = null;
    try {
    c = (HttpConnection)Connector.open(url);
                   if(c == null)
                        System.out.println("PKPK");
                   else
                        System.out.println("PSPS");
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("IF-Modified-Since", "20 Jan 2001 16:19:14 GMT");
    c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
    c.setRequestProperty("Content-Language", "en-CA");
    os = c.openOutputStream();
    String str = "name="+user;
    byte postmsg[] = str.getBytes();
    System.out.println("Length: "+str.getBytes());
    for(int i=0;i<postmsg.length;i++) {
    os.write(postmsg);
    // or you can easily do:
    // os.write(("name="+user).getBytes());
    os.flush();
    is = c.openDataInputStream();
    int ch;
    while ((ch = is.read()) != -1) {
    b.append((char) ch);
    System.out.print((char)ch);
    } finally {
    if(is!= null) {
    is.close();
    if(os != null) {
    os.close();
    if(c != null) {
    c.close();
    //display.setCurrent(t);
         public void run()
              try
                   invokeServlet(url);
                   TextBox t = new TextBox("Second Servlet", b.toString(), 1024, 0);
                   t.addCommand(backCommand);
                   t.setCommandListener(this);
                   display.setCurrent(t);
              catch(Exception ex){}     
         public void refreshScreen(StringBuffer b)
              TextBox t = new TextBox("Second Servlet", b.toString(), 1024, 0);
              t.addCommand(backCommand);
              t.setCommandListener(this);
              display.setCurrent(t);
    public void commandAction(Command c, Displayable d)
    String label = c.getLabel();
    if (label.equals("Exit")) {
    destroyApp(true);
         else if (label.equals("Back")) {
    mainMenu();
         else if (label.equals("Submit"))
    user = input.getString();
    // try {
    //invokeServlet(url);
              thread = new Thread(this);
              thread.start();
              // catch(IOException e) {}
         else {
    addName();
    //Servlet side
    public class RequestServlet extends HttpServlet {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    BufferedReader br = request.getReader();
    String buf = br.readLine();
              System.out.println("LSLS");
    out.print("Rec: "+buf);

    Hi,
    Since you use POST Method for the request, you have to implement the doPost(...) Method in the servlet, right? Do a simple implementation of the doGet(...) Method and call the Servlet using a browser. So you can easily check, whether the Servlet is available or not. You got the Error 404 which means, that the Servlet cant be found on the Tomcat. Make sure, that it is deployed correctly and your URL in the MIDlet is also correct.
    hth
    Kay

  • Problem With Midlet Database Connectivity

    Hi, I am into an application which reures database connectivity.I want to connect to Ms Access as backend with JDBC support.Ive searched a lot but found RMS as the only answer.I will be very thankful if some one can send me a code snippet or some link to an article which shows the trail to my problem.

    You can't have an MS Access database on the phone itself. And even if you can (on an MS SmartPhone maybe?), MIDP has no way to connect to it.
    But if you need to connect to a database that's hosted on a server, then what you have to do is set up a regular web server (using ASP, Servlets, PHP, whatever you fancy), and communicate with this server using the General Connection Framework (that's the javax.microedition.io.* classes). The web server, instead of outputting data in HTML format, can output the data in a format you design and know how to read and parse on your MIDlet (for example, for a simple application a comma separated string will do, for something more complicated maybe you want to use XML, or even develop your own binary format).
    If you want the data to be stored on the client then I'm afraid you're stuck with the RMS.
    shmoove

  • Problem with servlet connection

    Hi guys,
    Im gettin an nullpointer exception when connect to a servlet. Some "abstract" code:
    public void connect()
    servletConnection = servletURL.openConnection();
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setDefaultUseCaches (false);
    servletConnection.setDoInput(true);
    servletConnection.connect();     
    servletInput = new ObjectInputStream(servletConnection.getInputStream());
    public codeThatWorks()
    while(true)
    connect()
    usereceivedvalues();
    public codeThatDontWorks()
    connect()
    while(true)
    usereceivedvalues();
    I dont know why I have to reconnect to the servlet or renew the ObjectInputStream everytime I need to get values from it. Im using a ObjectInputStream to get the values from the servlet.
    Some ideas ? Thankss.

    I think your problem is in servlet. You can try the servlet without midlet in a IExplorer browser.
    ps1=con.prepareStatement("SELECT * FROM userLogin where uID=?");
    ps1.setString(1,uID);
    ResultSet re=ps1.executeQuery(); It is posible that re will be null.

  • Servlet connection to mssql

    i want to connect servlet to mssql database on server.....i hv already created database from mssql server 2005....i hv written code for servlet.....but i dint getting wht should i write in Class.forname(); wht will be the URl also.....i hv sqljdbc.jar....how to do connection with database...

    try
      java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      Connection c = java.sql.DriverManager.getConnection("jdbc:sqlserver://MY-PC\\SQLEXPRESS;IntegratedSecurity=True");
      System.out.println("Connected!");
    }catch(Exception ex){
      ex.printStackTrace();
    }

  • Oracle Servlet Connectivity

    Hello
    When i try to connect my servlet with oracle it didnt detect oracle driver. My Simple java class was connect successfully but when i move to servlet i didnt work. Classnotfoundexception Occur tell me what i do and where i place classes12.zip folder in tomcat server.
    Thank You
    Regards
    Uzair

    Rename the classes12.zip to be classes12.jar
    Tomcat only reads jar files, not zip files.
    It should be in one of the following (in my order of preference):
    - web-inf/lib
    - TOMCAT/shared/lib
    - TOMCAT/common/lib
    Cheers,
    evnafets

  • Servlets & connection

    We develop servlets and creation of connection was replaced in init() method. But if many people work at the same time
    then Excpetion "not streaming mode" was generated.
    public class viewReport extends HttpServlet
    Connection conn;
    public void init(ServletConfig config) throws ServletException
    try
    {super.init(config);
    Class.forName (oracle.jdbc.driver.OracleDriver);
    conn = DriverManager.getConnection (jdbc:oracle:thin:@Uran:1521:ORCL,
    "scott", "tiger");
    conn.setAutoCommit(false);
    catch(Exception err)
    If we remove
    conn = DriverManager.getConnection (jdbc:oracle:thin:@Uran:1521:ORCL,
    "scott", "tiger");
    in the doGet() and doPost() methods nothing exception was trown.
    Therefore it is necessary that One request = One connection. Is it true?
    On the site Sun I read that we can create connection in the init() method. But this is not true in fact.
    Thank you
    null

    "...I thought it would be easier if I just used a connectionpool.java file that i got from a book..."
    I guess you'll find out. Depends on how good the book is, I guess.
    .class files for Web apps always go in the WEB-INF/classes directory, of course. If they have a package statement, which they must for Tomcat, the package directory structure must be reproduced under WEB-INF/classes.
    That's runtime. Compiling is different. The error is telling you that you didn't put that class in the CLASSPATH when you compiled:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    MOD

  • ORA-12519 with servlet connect

    Hi,
    I'm facing a strange behaviour on my tomcat webserver with a servlet. I'm using Oracle 10g as the database and try to access it with my servlet.
    The doPost-method throws the following exception while trying to establish the connection to the RDBMS:
    "SQLException:
    Connecting not possible:
    Listener refused the connection with the following error:
    ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was: localhost:1521:DBTEN"
    After starting my servlet, the connection to the database for other applications blocks with the same error message
    for a few minutes. After these few minutes connecting to the database is possible again!!! Restarting the database and the listener also helps...
    public void doPost( HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException {
    Connection conn = null;
    response.setContentType( "text/html" );
    PrintWriter out = response.getWriter();
    String connStr = "jdbc:oracle:thin:@localhost:1521:DBTEN";
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    }catch( ClassNotFoundException cnf ){
    out.println( "CNFException: "+cnf.getMessage() );
    //retrieve Connection
    try{
    conn = DriverManager.getConnection( connStr, "scott", "tiger" );
    }catch( SQLException sqle ){
    out.println( "SQLException: <BR> Connecting not possible: <BR> "+sqle.getMessage()+"<BR>" );
    When I put that part in a 'normal' main program everything is ok. I can connect to the database and access tables with select statements and everything is ok.
    public static void main(String[] args) {
    Connection conn = null;
    //retrieve Connection
    try{
    String connStr = "jdbc:oracle:thin:@localhost:1521:DBTEN";
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    }catch(ClassNotFoundException cnf){
    System.out.println( "CNFException: "+cnf.getMessage() );
    conn = DriverManager.getConnection( connStr, "scott", "tiger" );
    }catch( SQLException sqle ){
    System.out.println( "SQLException:"+sqle.getMessage() );
    Does anyone have an idea what the problem is in this case?
    Regards,
    Lars

    "Note: The use of the DriverManager class to establish a connection to a database is deprecated." --
    http://download-uk.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25320/getconn.htm
    To open a connection use something like this:
    OracleDataSource ods = new OracleDataSource();
    ods.setUser("username");
    ods.setPassword("password");
    ods.setURL("jdbc:oracle:thin:@localhost:1521:XE");
    ods.getConnection();
    Instead of this:
    Class.forName("oracle.jdbc.OracleDriver");
    DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "username", "password");

  • JDBC/Servlets Connectivity Problems.

    Hi,
    I'm new to Java development.
    I'm trying to run this simple Servlet on
    OS : Sun Solaris 2.6
    Web Server : Netscape Enterprise Server
    Database : Oracle 8i
    JDK2 and JSDK2 installed on the Server.
    JDBC Driver : Native Oracle JDBC Driver
    This program works perfect on the Server if I run it as a program (Not a Servlet). However when running it as a Servlet, JUST DOESN't do ANYTHING. Doesn't return any error nor does execute the SQL Command.
    Also how can I enable tracing to Trap errors generated on the Server by the Servlet.
    Thanks for all your help....
    Here's the Pogram:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class CreateTable1 extends HttpServlet {
    public void init(ServletConfig config)
    throws ServletException {
    super.init(config);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    ServletOutputStream out = response.getOutputStream();
    out.println("<html>");
    out.println("<head><title>CR2Reat Table Server</title></head>");
    out.println("<body>");
    out.println("<br>Before Create...");
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection con = DriverManager.getConnection("jdbc:oracle:kprb:@oracle","uername","password");
    Statement statement = con.createStatement();
    statement.executeUpdate("CREATE TABLE kj_newCont1" +
    "(title_id NUMBER, title_name VARCHAR2(50)," +
    "rating CHAR(5), price NUMBER(7,2), quantity NUMBER," +
    "type_id INTEGER, category_id INTEGER)");
    catch (SQLException sqle) {
    System.err.println(sqle.getMessage());
    catch (Exception e) {
    System.err.println(e.getMessage());
    out.println("<br>AfterClose");
    out.println("</body></html>");
    out.close();
    public String getServletInfo() {
    return "Title Servlet return Information...";
    null

    To run servlets you must have a special server to run them like JRun or Java Web Server visit www.allaire.com to download JRun
    You must also download the servlet.jar
    java.sun.com
    you must configure your CLASSPATH too
    CLASSPATH=".:<path>classes12_01.zip":".:<path>servelet.jar"
    I'm using Red Hat Linux 6.2 I think this can Help you

  • Help! MIDlet wont Connect to HTTPS backend.

    I developed a midlet for accessing a web service within my company and the midlet works perfectly in the emulator but not in the phones. Whenever I try to run the midlet in the phone, it just hangs on any web service requests and doesnt do anything. It doesnt even try to connect to the HTTPS backend.
    The midlet is not signed but does require the HTTPS permission in the JAD file so I would think that it should ask the user if its ok to connect but it doesnt do that either. its really getting on my nerves.
    Can anyone help with this? Does the jar have to be signed to connect? Is there something Im missing in the midlet ?

    Are you catching any errors that your program might be throwing. Even though it works on the emulator make sure that you are catching and printing out any exceptions. It sounds like your program might be throwing an exception but if you're not doing anything with it than it will just appear as in the program is hanging.

  • Servlet connection refused: connect

    here my problem can any one help
    javax.servlet.ServletException: XML Parsing error: IOException: Connection refused: connect
         at net.athenet.cable.LocationSubmitAction.run(LocationSubmitAction.java:57)
         at net.athenet.cable.ControllerServlet.doPost(ControllerServlet.java:118)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

    I am using Jdeveloper 10.1.3.0.4

  • Servlet connecting to MS SQL

    Hi guys....... i am having problems connecting to MS SQL server. I think this may be due to the configuration of the USERID and PASSWORD during the ODBC setting, but after much meddling, it still didnt work. Below is e code i used.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.internetcds.jdbc.tds.*;
    public class sample extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    try {
    System.out.println("Before Class " );
    PrintWriter out=null;
    Class.forName("com.internetcds.jdbc.tds.Driver");
    System.out.println("Before Connection " );
    java.sql.Connection Conn = (java.sql.Connection)java.sql.DriverManager.getConnection("jdbc:freetds:sqlserver:SQLServer","sa","password");
    System.out.println("Before Statement" );
    java.sql.PreparedStatement st = (java.sql.PreparedStatement)Conn.prepareStatement("select * from test");
    java.sql.ResultSet rs = st.executeQuery();
    while(rs.next()) {
    System.out.println(rs.getString(1));
    } catch(Exception e) {
    i haven got any error compiling
    but it dun seem to be able to read this line
    java.sql.DriverManager.getConnection("jdbc:freetds:sqlserver:SQLServer","sa","password");
    I dun think i downloaded any driver, but i did download the .jar file for it though
    Experts Please advice........ thanx

    IMHO you don't have to import the com.internetcds.jdbc.tds.* because you import it via
    Class.forName("com.internetcds.jdbc.tds.Driver");.
    Please print the stacktrace.
    Use
    } catch(Exception e) {
    e.printStackTrace()
    }instead
    } catch(Exception e) {
    e.printStackTrace()
    }and post the error message.
    Be sure that the lib from com.internetcds is in a directory from your webserver where it is loaded.
    Dietmar

  • Applet Servlet Connection

    Hi,
    I am trying to develop a chatroom application. I am using a applet as client which communicates with a servlet by recieving and sending a serialized object.
    This is done by using the URLConnection class.
    If one user send a message to the servlet then the servlet needs to send that message to all user in the chatroom.
    Herefore I need the connections to each applet. I need to store each connection to the applet of the user.
    How can implement this?
    Thanks

    Maybe you should open a socket connection from the applet to the servlet instead of using URLConnection. There is a tutorial on sockets on the java.sun.com site.

Maybe you are looking for

  • Partner functions for a specific customer not seen in XD03 but appears in XD02

    Hello SAP Gurus, I have a situation where a partner functions for a specific customer not seen in XD03 but appears in XD02, In XD03 only one partner function (Ship to) appears but in XD02 (Sold to, Ship to, Bill to and payer appears), from the custom

  • Cycle count Storage location selection

    Hi, Could someone explain to how the Storage locations are selected when I run transaction MICN. Our settings in config are like this I have a material in one storage location, it has never been counted. I run the transaction MICN for that material i

  • Question about asp access

    Hi. I'm trying to get information from a MS Access database to a Java applet. I think the easiest way to do this is to use ASP. I got the asp page working to access the database and print its contents but I have no idea how the applet can access that

  • Lightroom CC Crashes when selecting 1:1 crop

    Anyone else having this issue?  As soon as I select a square 1:1 crop the app crashes.

  • Making a public hotspot

    Hey, I'd like to leave an Airport Extreme (N) at work and allow clients to use it as a wifi hotspot... Is there a way that I can block access to local LAN resources (like shared files and folders) through the Airport. Thanks!