request.getParameter() returning NULL
Hi,
I have a developed a J2ME application which is communicating to a servlet, but when I do "request.getParameter("GPRSDATA")", NULL is returned, I have even removed "flush()" in J2ME client, still it is null.
Help, Urgent!!!
//J2ME code
publicvoid openConnection()throws Exception{
new Thread(){
publicvoid run(){
try{
/** Initialize HTTP objects */
initializeHttp();
//Now Check GPRS connectivity,Send Some Data to the server and wait for the response
//If response received then connection is successful
byte[] gprs_data = ("GPRSDATA=" + gprsStr).getBytes();
outputStream.write(gprs_data);
//outputStream.flush();
outputStream.close();
System.out.println("Request Sent");
int status = http.getResponseCode();
System.out.println("Response");
if(status == HttpConnection.HTTP_OK){
System.out.println("Ok");
//Get the response
inputStream = http.openInputStream();
handlehttpResponse(http, inputStream);
}else{
thrownew Exception("Connection Error");
}
}catch(Exception exception){
System.out.println("Exception in HttpHandler :" + exception.getMessage());
}/*finally {
closeConnection();
}*/
}
}.start();
}
/**
* This will setup the HTTP object and sets the request method and the property
* @throws IOException
*/
publicvoid initializeHttp()throws IOException{
http = (HttpConnection) Connector.open(url);
outputStream = http.openOutputStream();
http.setRequestMethod(HttpConnection.POST);
http.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
}
In servlet
protectedvoid doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
System.out.println("Encoding: " + request.getCharacterEncoding());
System.out.println("Length: " + request.getContentLength());
System.out.println("Contxt Path: " + request.getContextPath());
System.out.println("Servlet Path: " + request.getServletPath());
System.out.println("Attribute Names: " + request.getAttributeNames());
//[b]Null[/b] is returned Here
System.out.println("Raaghu GPRSDATA HTTP Request :" + request.getParameter("GPRSDATA"));
/*PrintWriter printWriter = response.getWriter();
String str = "<html><head></head><body>This is sure to work</body></html>";
printWriter.write(str);*/
OutputStream outputStream = response.getOutputStream();
//outputStream.write(gprs_data);
outputStream.flush();
}
//output on console
Encoding:null
Length: 14
Contxt Path: /DDDD
Servlet Path: /J2MEServlet.do
Attribute Names: org.apache.catalina.util.Enumerator@1038de7
Raaghu GPRSDATA HTTP Request :null
Thanks in Advance
Raaghu.K

