Hi,


I have J2ME app that send and receive information from a server (servlets with Tomcat 6.0).

In first step the user have to be authenticated. The client app send authentication data and the servlet ejecute a stored procedure (MySQL) to validate the user and return a id user. While the app is open user is sending his id evry request to perform some operations.

The app work fine in sigle cell phone but if I try to login with other device immediatly after that with wrong authentication data I receive always the user id on the first device thah was successfull signed. Probably this has to do with cache, if this this is the case how can I solve this?What is the better way to implement simple authentication?


This is snippet of client side code:


httpCon =(HttpConnection)Connector.open(url, Connector.READ_WRITE, true);
httpCon.setRequestMethod(HttpConnection.POST);
httpCon.setRequestProperty("Content-Language", "en-US");
httpCon.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");
httpCon.setRequestProperty("Accept", "application/octet-stream");
httpCon.setRequestProperty("Pragma","no-cache");
httpCon.setRequestProperty("Cache-Control","max-age=0, no-cache, no-store, must-revalidate, no-transform");
httpCon.setRequestProperty("Connection", "close");




ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(imei);
dos.writeUTF(password);
dos.writeUTF(clave);
//dos.writeInt(driver_status);
byte[] datos = baos.toByteArray();
httpCon.setRequestProperty("Content-Length", "" + datos.length);


try {
os = httpCon.openOutputStream();
os.write(datos);
os.close();
dos.flush();
dos.close();



And this is snippet of server side code:


ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeInt(status);
if(status == 99) {
dos.writeInt(id);
}
dos.close();

byte[] datos = baos.toByteArray();
sendedBytes = datos.length;
response.setContentType("application/octet-stream" );
response.setContentLength(sendedBytes);

response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","max-age=0, no-cache, no-store, must-revalidate, no-transform");




OutputStream os = response.getOutputStream();
os.write(datos);
os.close();

if (cstmt !=null)try { cstmt.close(); }catch(Exception e) {}
if (con !=null)try { con.close(); }catch(Exception e) {}



The imei, password and clave have the same length every request. Having thi is mind and the fact that I'm using binary stream to send an receive the information, it sounds like there is some cache. ???