Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I'm implementing Session Handling in MIDP for this i've build application using following reference,

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);
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++) {
// or you can easily do:
// os.write(("name="+user).getBytes());

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 = != -1) {
b.append((char) ch);
t = new TextBox("Second Servlet", b.toString(), 1024, 0);
} finally {
if(is!= null) {
if(os != null) {
if(c != null) {

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?

Sachin Warang.
sachin warang
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

Check out the discussion on this issue,

Sachin Warang.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!