j2me connection to spring security <p>I have an application that use spring security for authentification I m trying to connect to this application from j2ME midlet</p> <p>so I am sending an HTTP request from a j2me application using the post method to send username and the password but it doesn't work</p> <p>the post methode code is fine. it works with other services of the same application (which not require authentification)</p> <p>but when it comes to authentification I'm getting the response code 302</p> <p>here is my code</p> <pre><code> OutputStream os = null; HttpConnection connection = null; InputStream is = null; StringBuffer sb = new StringBuffer(); try { connection = (HttpConnection)Connector.open("http://localhost:8080/myAppli/j_spring_security_check"); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); os = connection.openOutputStream(); byte data[] =("j_username=appliusername&amp;j_password=applipassword").getBytes(); os.write(data); os.flush(); int respCode=connection.getResponseCode(); if (connection.getResponseCode() == HttpConnection.HTTP_OK) { is = connection.openInputStream(); if (is != null ) { int ch = -1; while ((ch = is.read()) != -1) { sb.append((char)ch); } } }else { System.out.println("Error in opening HTTP Connection. Error#" + respCode); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (is != null) { is.close(); //is = null; } if (os != null) { os.close(); //is = null; } if (connection != null) { connection.close(); // connection = null; } }catch (Exception e2) { e2.printStackTrace(); } } </code></pre>