Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:14:28+00:00 2026-06-03T06:14:28+00:00

I am new to J2ME and am building a mobile application where users can

  • 0

I am new to J2ME and am building a mobile application where users can register, login and be presented with some member only screen where they can perform some operations.

(I am into web development, hence kindly correct me where I use a web approach. Also, I clearly understand basic java concepts but have not built a mobile app before)

So far, I have created the first screen with a login form containing a username and password textbox, and Login and Exit buttons.

The problems I am currently facing are:

  1. How can I provide access to Register, Login and Exit at the same time (it seems the phone can only have two buttons at a time). Do I provide them as command buttons or normal ‘web like buttons that appear on page’? Kindly tell me how for any of the options that seems appropriate.

  2. How do I send and receive data over http in the mobile application? Sample code will be appreciated.

  3. How do I manage the different screens? In web development, I simply create pages and link them up. In this case, how can I display a register screen when the register button is pressed? The home screen when login is successful? or an error message when unsuccessful?

Do I have different functions that dynamically generates the screens? and I call them each time when the screens are requested?

Simple samples will be highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:14:29+00:00Added an answer on June 3, 2026 at 6:14 am

    In J2ME,

    You have the display object which determines what is shown on the screen. There are something which can be displayed. For example a Form, List, Textbox etc. Therefore what you can do is you can create the following displays

    public class IndexScreen extends List implements CommandListener {
    
        //This will contain the options 
        //1. Register
        //2. Login
        //3. Exit
    }
    
    
    public class RegsterScreen extends Form implements CommandListener {
    
        //This will contain register fields and submit cancel command buttons
    
    }
    
    public class LoginScreen extends Form implements CommandListener {
    
       //This will contain Login specific controls
    }
    

    Now once these displayable objects are ready you can keep changing the display on some events like click of a command button.

    public void commandAction(Command c, Displayable d) {

        if (c == OK) {
            nextScreen = new RegisterScreen();
            display.setCurrent(nextScreen);
        }
        if (c == BACK) {
            display.setCurrent(prevScreen);
        }
    

    For sending and receiving data the following may help….

    package madmin.client;
    
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.lcdui.Display;
    import madmin.res.Globals;
    
    
    public class ClientRequest {
    
    private Client client;
    private Display display;
    private String requestServlet;
    private String requestCode;
    private String requestId;
    private String userId;
    private String url;
    private String response;
    private String parameterOne;
    
    
    
    public ClientRequest() {
    
    }
    
     public boolean sendRequest() {
    
          boolean result = false;
          userId = Globals.getUserId();
          url = Globals.getURL() + requestServlet + "?requestCode=" + requestCode + "&requestId=" + requestId + "&userId=" + userId + "&clientIP=" + client.getIpAddress() + "&clientHostName=" + client.getHostname() + "&parameterOne=" + parameterOne;
    
          System.out.println("User Id value in ClientRequest " + userId);
    
    
          System.out.println("Start HTTP Connection");
          HttpConnection connection = null;
          InputStream inputstream = null;
    
           try {
                connection = (HttpConnection) Connector.open(url);
                connection.setRequestMethod(HttpConnection.GET);
                connection.setRequestProperty("Content-Type", "//text plain");
                connection.setRequestProperty("Connection", "close");
    
                System.out.println("Status Line COde: "+ connection.getResponseCode());
                System.out.println("Status Line Message: "+ connection.getResponseMessage());
    
    
                if(connection.getResponseCode()==HttpConnection.HTTP_OK){
                    inputstream = connection.openInputStream();
                    int length = (int) connection.getLength();
                    if(length!=-1){
                        byte incomingData[] = new byte[length];
                        inputstream.read(incomingData);
                        response = new String(incomingData);
                    }
                    else {
                        ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
                        int ch;
                        while((ch = inputstream.read())!=-1){
                            bytestream.write(ch);
                        }
                        response = new String(bytestream.toByteArray());
                        bytestream.close();
                    }
    
                   System.out.println("Response:" + response.trim());
    
                   if(response.trim().equals("Request Submitted Successfully")){
                           result = true;
                   }
                   else{
                        result = false;
                   }
                }
                connection.close();
                if(inputstream!=null)inputstream.close();
            }
            catch(Exception e) {
                e.printStackTrace();
            }
            finally {
                if(inputstream!=null){
                    try{
                        inputstream.close();
                    }
                    catch(Exception e){
                        e.printStackTrace();
                    }
                }
            }
         return result;
     }
    
    public Client getClient() {
        return client;
    }
    
    public void setClient(Client client) {
        this.client = client;
    }
    
    public Display getDisplay() {
        return display;
    }
    
    public void setDisplay(Display display) {
        this.display = display;
    }
    
    public String getRequestCode() {
        return requestCode;
    }
    
    public void setRequestCode(String requestCode) {
        this.requestCode = requestCode;
    }
    
    public String getRequestId() {
        return requestId;
    }
    
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }
    
    public String getRequestServlet() {
        return requestServlet;
    }
    
    public void setRequestServlet(String requestServlet) {
        this.requestServlet = requestServlet;
    }
    
    public String getResponse() {
        return response;
    }
    
    public void setResponse(String response) {
        this.response = response;
    }
    
    public String getUrl() {
        return url;
    }
    
    public void setUrl(String url) {
        this.url = url;
    }
    
    public String getUserId() {
        return userId;
    }
    
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    public String getParameterOne() {
        return parameterOne;
    }
    
    public void setParameterOne(String parameterOne) {
        this.parameterOne = parameterOne;
    }
    

    }

    and….

    package madmin.client;
    
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import madmin.res.Globals;
    
    
    public class ClientResponse {
    
    private String response;
    
    
    public String getResponse(String requestId) {
    
             System.out.println("Start HTTP Connection");
             HttpConnection connection = null;
             InputStream inputstream = null;
             response = "";
    
              try{
    
                connection = (HttpConnection) Connector.open( Globals.getURL() + "ResponseServlet?requestId=" + requestId);
                connection.setRequestMethod(HttpConnection.GET);
                connection.setRequestProperty("Content-Type", "//text plain");
                connection.setRequestProperty("Connection", "close");
    
                System.out.println("Status Line COde: "+ connection.getResponseCode());
                System.out.println("Status Line Message: "+ connection.getResponseMessage());
    
                if(connection.getResponseCode()==HttpConnection.HTTP_OK){
                    inputstream = connection.openInputStream();
                    int length = (int) connection.getLength();
                    if(length!=-1){
                        byte incomingData[] = new byte[length];
                        inputstream.read(incomingData);
                        response = new String(incomingData);
                    }
                    else {
                        ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
                        int ch;
                        while((ch = inputstream.read())!=-1){
                            bytestream.write(ch);
                        }
                        response = new String(bytestream.toByteArray());
                        bytestream.close();
                    }
    
                   System.out.println("Response:" + response.trim());
    
                  connection.close();
                  if(inputstream!=null)inputstream.close();
                }
                }
                catch(Exception e){
    
                    e.printStackTrace();
                }
    
        return response;
    }
    }
    

    edited:
    something like this

         public class MenuScreen extends List implements CommandListener{
    
         public MenuScreen() {
     append("Register", null);
         append("Login", null);
         append("Forgot password", null);
    
    
         select = new Command("Select", Command.OK, 1);
         addCommand(select);
         setCommandListener(this);
    

    }

    }

         public void commandAction(Command command, Displayable display) {
    
          if(command==List.SELECT_COMMAND){                 
            String menuItem = this.getString(menuIndex);
          }
    
          if(command==select){       
            if( menuItem.equals("Register"))
         display.setCurrent(new RegisterScreen())
     }
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to J2ME application development, I want to write an ANT script to
I am new to J2me, kindly can anybody tell me how can I do
I have an j2me application installed on a Nokia S40. Some configuration data is
I made the simple j2me login application, code is below. It's working perfectly on
I am trying to program a very simple Mobile Application (J2ME) in java. The
I'm new in symbian mobile applications. I'm developing webservices related application in this webservices
I am new in J2ME. In my Application, I have to store a large
I am new to J2ME application development. Normally I have developed j2me apps for
As I am new to j2me,I am trying to upload image from mobile in
I am new to j2me and i am trying to develop an application.There is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.