Java Programing laungage

J2ME Projects

J2ME Project 1

adplus-dvertising
Introduction about Connectivity of JME (Midlet) to Servlet
Previous Home Next

Introduction

The HTTP Programming Model

The HTTP protocol is a request-response application protocol in which the parameters of the request must be set before the request is sent. HTTP provide three method GET, POST, and HEAD for send data to server either Web server or Application server. These methods determine how the data is sent to the server. Servlets run within the same process as the HTTP server.

When a client request is made, the service method (which extend Generic Servlet) is called and passed a request and response object. The servlet first determines whether the request is a GET or POST operation, then calls either the HttpServlet.doGet or HttpServlet.doPost method as appropriate. Both the doGet and doPost methods take request (HttpServletRequest) and response (HttpServletResponse) objects as parameters. Then the servlet constructs a response that the server sends back to the client.

Configure Servlet and JME application

Consider following steps for configure servlet into JME profile.

Required - Software or Resource

  1. NetBeans IDE -7.0
  2. Java Development Kit (JDK) - 1.6
  3. Java Platform Micro Edition SDK 3.0
  4. Server - Apache Tomcat -7.0.11

Step -1:Create a web application and named as a MobileServlet.

Step -2:Create a Mobile application and named as a r4r.mobileServlet.

Step -3:Configure web application to Server, either Web server (like Apache Tomcat ) or Application server (like GlassFish Server).

Step - 4:The web.xml file is the Web Application Deployment Descriptor, which defines which servlets should be run for certain URLs and some other parameters of your web application.

Step -5:Run Apache Tomcat Server. Run web application (MobileServlet), Netbeans IDE Used 8084 port for Tomcat Server and 8080 port for GlassFish server. So URL will be of the format http://localhost:8084/(your web app)/(your jsp or servlet>).

Step -6:Midlet (or client ) class can access servlet through this URL.

Previous Home Next