dcsimg
How to foce Nokia 7210 SDK to use HTTP rather than WAP?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, September 28, 2003 05:02 AM

Hi there, In the Nokia 7210 Emulator, I click File -> New and i enter my ip address called: http://127.0.0.1:8081/chii2/servlet/HelloServletExample    More>>















Hi
there,



In the Nokia 7210 Emulator, I click File -> New



and i enter my ip address called:




http://127.0.0.1:8081/chii2/servlet/HelloServletExample




I can't get the phone to access it...



so I play with the Tools -> Settings



and under Wap Networking, the gateway ip is 127.0.0.1 (i
try to set it to 0.0.0, but can't work)



and under the MIDlet Networking, i already check the
Enable HTTP communication checkbox.



To QC, i go to Tools -> Status Window



AND I notice that no matter what it still goes to WAP
Communication Requests 1 (the counter will increment)



The HTTP Communication, Request still 0. (i try to
connect to the internet, also http request is still 0)



Sad story, so i do some coding in servlest and midlets



Well i learn from the java sun website...



Below is the source code:



FirstMidletServlet.java

================



import java.io.*;

import javax.microedition.io.*;

import javax.microedition.lcdui.*;

import javax.microedition.midlet.*;



/**

* An example MIDlet to invoke a CGI script.

*/



public class FirstMidletServlet extends MIDlet {

private Display display;

String url =

"http://127.0.0.1:8081/chii2/servlet/HelloServletExample";



public FirstMidletServlet() {

display = Display.getDisplay(this);

}



//Initialization. Invoked when MIDlet activates

public void startApp() {

try {

invokeServlet(url);

} catch (IOException e) {

System.out.println("IOException " + e);

e.printStackTrace();

}

}



//Pause, discontinue ....

public void pauseApp() { }



//Destroy must cleanup everything.

public void destroyApp(boolean unconditional) { }



//Prepare connection and streams then invoke servlet.


void invokeServlet(String url) throws IOException {

HttpConnection c = null;

InputStream is = null;

StringBuffer b = new StringBuffer();

TextBox t = null;

//Form t = null;

try {

c = (HttpConnection)Connector.open(url);

c.setRequestMethod(HttpConnection.GET);

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");

is = c.openDataInputStream();

int ch;



// receive response and display it in a textbox.

while ((ch = is.read()) != -1) {

b.append((char) ch);

}

t = new TextBox("First Servlet",



b.toString(), 1024, 0);

// t = new Form(b.toString());

} finally {

if(is!= null) {

is.close();

}

if(c != null) {

c.close();

}

}

display.setCurrent(t);

}

}



HelloServlet.java

============

import java.io.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;



/**

* The simplest possible servlet.

*/



public class HelloServlet extends HttpServlet {

public void doGet(HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

response.setContentType("text/plain");

PrintWriter out = response.getWriter();

out.println("Servlet invoked!");

out.println(new Date());

}

}



And it works fine. I can see now it goes directly to
Http rather than Wap anymore.



*Note: The servlets and compilation of the java works
fine.



Any idea. How to make the emulator possible to
"force-to-point" at HTTP rather than WAP.



Thanks.



Regards,

Chua Wen Ching :p



   <<Less
About | Sitemap | Contact