Hello Friends,
I made servlet for database connection..
Its working fine on Tomat & IIS Also.
but when i try to send data from Servlet to my J2ME platform it is not sending ...
I'm unable to find where is problem..
Need Help
Printable View
Hello Friends,
I made servlet for database connection..
Its working fine on Tomat & IIS Also.
but when i try to send data from Servlet to my J2ME platform it is not sending ...
I'm unable to find where is problem..
Need Help
What do you mean by "sending data"?
Are you getting any errors?
Is your J2ME client calling the servlet (how?) then the servlet gets data from the db and returns that data in some way back to the client?
In other words, you have not provided anywhere near enough information.
i'm using DataOutput & Datainput stream for send data between servlet & j2me......
but on j2me side i'm getting error .."java.io.IOException: Error in HTTP operation"
but when i'm using Tomcat server that case work properly.....
so i'm not getting where is actual problem either servlet or j2me.......
Why are you using a DataOutputStream?
You might need to show us some code from the servlet, because it looks like you're not sending the correct stuff.
in servlet :-
protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
// processRequest(request, response);
DataInputStream INPUT_STREAM = new DataInputStream(request.getInputStream());
String sText = " "+INPUT_STREAM.readUTF();
INPUT_STREAM.close();
DataOutputStream OUTPUT_STREAM = new DataOutputStream(response.getOutputStream());
OUTPUT_STREAM.writeUTF(sText);
OUTPUT_STREAM.flush();
OUTPUT_STREAM.close();
}
in J2ME:---------------------------------
private void da()
{
HttpConnection connection = null;
DataInputStream dataInputStream = null;
DataOutputStream dataOutputStream = null;
try
{
connection=(HttpConnection) Connector.open("http://localhost:8084/TestServlet/Test/",Connector.READ_WRITE,false);
connection.setRequestProperty("User-Agent", "Profile/MIDP-2.0, Configuration/CLDC-1.1");
connection.setRequestProperty("Content-Language", "en-US");
connection.setRequestMethod(HttpConnection.POST);
dataOutputStream = connection.openDataOutputStream();
dataOutputStream.writeUTF("asasaasas");
// dataOutputStream.flush();
dataOutputStream.close();
dataInputStream = connection.openDataInputStream();
dataInputStream.close();
connection.close();
}
catch(Exception e)
{
System.out.println("Error In Collect : "+e);
}
}
In your catch block do a stack trace.
That should tell you where it's being thrown from.
getting same error
javax.microedition.io.ConnectionNotFoundException: Could not resolve hostname
That's not the same error.
And now you know why it's not working...it couldn't find the host.
Also, one of the reasons for doing the stack trace was to identify where the exception was happening.
Part of debugging is to locate where a problem happens...so on a forum like this we expect to be told not just what exception, but where exactly it was thrown.
Thanks for support....