×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    76

    Question Problem while building session with doPost method (at server side)

    Hi friends,
    I'm implementing Session Handling in MIDP for this i've build application using following reference,

    http://developers.sun.com/techtopics...cles/sessions/

    This code work fine for doGet method at server side .But as i want send large data i've change the doGet tp doPost .
    With following changes at Client side:

    void invokeServlet(String url) throws IOException {
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    StringBuffer b = new StringBuffer();
    TextBox t = null;
    try {
    c = (HttpConnection)Connector.open(url);
    c.setRequestMethod(HttpConnection.POST);
    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");

    os = c.openOutputStream();
    String str = "name="+user;
    byte postmsg[] = str.getBytes();
    System.out.println("Length: "+str.getBytes());
    for(int i=0;i<postmsg.length;i++) {
    os.write(postmsg[i]);
    }
    // or you can easily do:
    // os.write(("name="+user).getBytes());
    os.flush();

    is = c.openDataInputStream();
    // sendRequest(url,hc);
    if (mSessionIDCookie != null)
    c.setRequestProperty("Cookie", mSessionIDCookie);

    String cookie = c.getHeaderField("Set-Cookie");
    System.out.println("cookie : "+cookie);
    if (cookie != null) {
    int semicolon = cookie.indexOf(';');
    mSessionIDCookie = cookie.substring(0, semicolon);
    System.out.println("mSessionIDCookie : "+mSessionIDCookie);
    }




    int ch;
    while ((ch = is.read()) != -1) {
    b.append((char) ch);
    System.out.print((char)ch);
    }
    t = new TextBox("Second Servlet", b.toString(), 1024, 0);
    t.addCommand(backCommand);
    t.setCommandListener(this);
    } finally {
    if(is!= null) {
    is.close();
    }
    if(os != null) {
    os.close();
    }
    if(c != null) {
    c.close();
    }
    }
    display.setCurrent(t);
    }

    But that doesn't help me?
    For doPost method it always created new session id at server side and at Client side it throws IOException ,how could i resolve this issue?
    How could i resolve this issue?

    Regards,
    Sachin Warang.

  2. #2
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    76

    Thumbs up Re: Problem while building session with doPost method (at server side)

    Hi friends,

    Check out the discussion on this issue,

    http://forum.java.sun.com/thread.jspa?messageID=4233772

    Regards,
    Sachin Warang.

Similar Threads

  1. can problem closing session
    By alice77 in forum Symbian C++
    Replies: 0
    Last Post: 2005-07-12, 12:17
  2. 6630 session cookies problem
    By chgossy in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2005-06-30, 07:45
  3. Object Exchange Server exe Problem
    By Naga Jyothi Venkata K in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-05-10, 09:42
  4. Problem Starting the server
    By Nokia_Archived in forum WAP Servers
    Replies: 1
    Last Post: 2002-05-14, 18:03
  5. Web server problem
    By Nokia_Archived in forum WAP Servers
    Replies: 2
    Last Post: 2002-05-14, 11:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •