Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

sachin warang

+ Follow
since May 04, 2006
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sachin warang

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.
12 years ago
Hi friends,
I'm using Servlet with MIDP .While sending a request to server we set some property like
conn.setRequestProperty( "User-Agent",
"Profile/MIDP-1.0 Configuration/CLDC-1.0" );
"Content-Language", "en-US" );

conn.setRequestProperty( "Accept",
"application/octet-stream" );

at Client side.
Which can be get at server (servlet) side.By
request.getHeader("User-Agent"); method.

Does there any RequestProperty exist from we set the device name at Client side(which later retrive at server side)?
Or is there any other way to do so?

Sachin Warang.
12 years ago
Hi friends,
I'm building chatServer in j2me using Servlet/Jsp.So while doing so i want to maintain a session.

For that i've invoke the following method,

HttpSession session = request.getSession(true);(in server)

But from that same MIDlet when i again send some text it again create new session id.
How could i resolve this issue as i just want to use same MIDlet when sending data to server?
Do i use diffrent Servlet/Jsp( at server side) when i going to send data after my session maintain?
But how could this new Servlet/Jsp( at server side) page get the same session id ?
Is there any other to resolve this ( want use only Session Tracking API)?

Sachin Warang.
12 years ago
hi friends,

I debug the code while doing so i realised that it is throwing SecurityException .
So edit the preferences> where in security i've change the settings to untrusted and restore the settings.
After clicking on OK .
The application works fine.

Sachin Warang.
12 years ago
Hi friends,

I'm using Session Tracking API.
where i set the attribute,
session.setAttribute( "Username", userID );
for all user who logged in.

Now while maintaing the session ,how can i get all the user's "Username" value who are logged in now.

Sachin Warang.
12 years ago
Hi friends,
I'm building Servlet in j2me.When i run this Servlet on web browser the Servlet running fine.But while in application when i used
conn = (HttpConnection) url );
where url = "http://localhost:8080/servlets-examples/hits"

It hangs ,the debugger stuck at this method .It didn't throw any Exception also.

Whats the problem?how could i resolve this issue?
I've used the follwing tutorial
to build servlet in MIDlet.

Sachin Warang.
12 years ago
Hi friends,
I want develop a chat server on mobile devices using jsp/servlet in j2me.I know jsp/servlet also.
But how to use it in j2me ?
While invoking the MIDlet device(emulator)send data to server(jsp/servlet) and the server transfer this data to another desired device(emulator).
Can anyone give some idea regarding this application like
how to start,any tutorials or examples ,any previos thread,any reference links regarding this chat server on j2me?

Sachin Warang.
12 years ago