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 6916565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:37:08+00:00 2026-05-27T09:37:08+00:00

I am developing an j2me application which is communicating with the database using servlet.

  • 0

I am developing an j2me application which is communicating with the database using servlet.
I want to store the data received from servlet into record store and display it.how this can be achieved?Please provide code examples.
Thank you in advance

 public void viewcon()
 {
  StringBuffer sb = new StringBuffer();

  try {
  HttpConnection c = (HttpConnection) Connector.open(url);
  c.setRequestProperty("User-Agent","Profile/MIDP-1.0, Configuration/CLDC-1.0");
  c.setRequestProperty("Content-Language","en-US");
  c.setRequestMethod(HttpConnection.POST);
  DataOutputStream os = (DataOutputStream)c.openDataOutputStream();

  os.flush();
  os.close();

  // Get the response from the servlet page.
  DataInputStream is =(DataInputStream)c.openDataInputStream();
  //is = c.openInputStream();
   int ch;
   sb = new StringBuffer();
   while ((ch = is.read()) != -1) {
   sb.append((char)ch);
       }
  // return sb;
   showAlert(sb.toString());//display data received from servlet 

    is.close();
    c.close();

              } catch (Exception e) {
                  showAlert(e.getMessage());
              }
        }
  • 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-05-27T09:37:09+00:00Added an answer on May 27, 2026 at 9:37 am

    Put this function call where you show the response data alert

    writeToRecordStore(sb.toString().getBytes());
    

    The function definition is as below:

    private static String RMS_NAME = "NETWORK-DATA-STORAGE";
    private boolean writeToRecordStore(byte[] inStream) {
        RecordStore rs = null;
        try {
            rs = RecordStore.openRecordStore(RMS_NAME, true);
            if (null != rs) {
                //Based on your logic either ADD or SET the record
                rs.addRecord(inStream, 0, inStream.length);
                return true;
            } else {
                return false;
            }
        } catch (RecordStoreException ex) {
            ex.printStackTrace();
            return false;
        } finally {
            try {
                if (null != rs) {
                    rs.closeRecordStore();
                }
            } catch (RecordStoreException recordStoreException) {
            } finally {
                rs = null;
            }
        }
    }
    

    After you have saved the data, read the records store RMS-NAME and check the added index to get the response data.

    .

    NOTE: The assumption is the network response data is to be appended to the record store. If you want to set it to a particular record modify the method writeToRecordStore(...) accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing the network application in which I want to run my J2ME
I'm developing j2me application and want to add a custom font into that.So how
I am developing a blackberry application using j2me and LWUIT (blackberry port). Everything works
recently I'm developing a J2ME application using LWUIT library, my application size is 679
I'm developing a j2me application using Netbeans IDE and LWUIT library. I need to
I'm developing a j2me application using Netbeans IDE and LWUIT library. I'm using Persian
currently, I am developing a J2ME application for mobiles using LWUIT library. The build
I'm developing a mobile application using J2me for a configuration CLDC-MIDP2.0. In my mobile
I'm developing a mobile application using J2ME for a configuration CLDC-MIDP2.0 . In my
I am developing a j2me map based application. Screen is divided into a grid

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.