MIDlet activation with Servlet, you can activate a CGI like the same MIDlet activation Servlet, this section will introduce two examples:
The first example of activation with GET operation Servlet, and displays the results.
The second example is the Servlet to accept user data from the phone onto POST
The following example of the content is, FirstMidletServlet activated by GET method and returns the display to the phone. In this case did not submit data to the Servlet, Servlet been activated for a return to the string "Servlet Invoked" and date to the client.
Here is the code FirstMidletServlet.java MIDlet
import java.io. *; import javax.microedition.io .*; import javax.microedition.lcdui .*; import javax.microedition.midlet .*; / bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp An example MIDlet to invoke a CGI script. backup / bin / conf / data / log / maint / svn / tmp / public class FirstMidletServlet extends MIDlet (private Display display; String url = "http://somesite.com/servlet/ HelloServlet "; 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; 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);) finally (if (is! = null) (is.close ();) if (c! = null) (c.close ();)) display.setCurrent (t );))
The following is to return "Servlet Invoked" and date code HelloServlet.java HelloServlet
import java.io. *; import java.util .*; import javax.servlet .*; import javax.servlet.http .*; / bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware backup bin conf config data eshow_sitemap.html generate.sh log maint sitemap.html svn tmp The simplest possible servlet . backup / bin / conf / data / log / maint / svn / tmp / public class HelloServlet extends HttpServlet (public void doGet (HttpServletRequest request
Servlet MIDlet is activated more than two examples.
Recommended links:
Save Delphi: Chinese open source community an excellent opportunity to display strength
Fastest Video Converter
BONUS of sight [2]
Firewall And Proxy Servers Comments
Recommend Registry Tools
Psp 6000
3DMax done USING NURBS baseball bat
CSS Syntax Guide (6) Categories Property
Gtalk and Skype will Interact
Photoshop font effects - ICE text
Online Wav To Mp3 Converter
MSN users frequently worry about Strangers raid computer data leakage
StartEx: Let The Desktop Shortcuts And Start Menu After Class!
m4a to mp3 CONVERTER
Zhang Feng: NAS really how it?