Forums Register Login

Testing an app for connecting to a servlet.

+Pie Number of slices to send: Send
hello

i�m trying to connect to a servlet using a midlet using the next code :

try {
c = (HttpConnection)Connector.open(url);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty("IF-Modified-Since","11 May 2005 15:17:19 GMT");
c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
c.setRequestProperty("Content-Languaje","en-CA");
c.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

os = c.openOutputStream();

os.write( ("nombre="+myname).getBytes() );
os.flush();

is=c.openDataInputStream();
int ch;
while( (ch = is.read()) != -1){
b.append( (char) ch );
System.out.print( (char) ch );
}
t= new TextBox("fecha", b.toString(),1024,0 );
t.setCommandListener(this);
} finally {
if(is !=null){
is.close();
}
if( os != null){
os.close();
}
if ( c !=null){
c.close();
}

now im using the netbeans 4.0 ide for test my code and this is
the message displayed : It is ok to use airtime ?

Apreciatelly Mark could u give me some tip for finalize my homework ?

regards
+Pie Number of slices to send: Send
You will always get this question if you do not have the SecurityPermission granted for using HttpConnection. Basically you are calling out to the internet, for most people this costs them money on their phone, so you can't just have an application connect and cost them money without getting their "approval".

That is what that message is, just select "yes" or "ok" to allow the connection.

When you get that message, there are a few options.

1. Just this once
2. For just this running of the application.
3. Always for this application, now and in the future.

Note that using the wireless toolkit, I believe it doesn't keep you last choice, so each time you run your app through the toolkit, you should be asked this question.

Mark
+Pie Number of slices to send: Send
thanks for ur comments mark , it is true that the user need to give permission for connect to the internet.

Now in my app, i answered with yes and nothing happens , so i've the same problem , and yes my code in the server is jsp .

any help would be appreciated.
+Pie Number of slices to send: Send
Well I don't think you can call a JSP page from J2ME.


I could be wrong, but with the JSP being converted into a Servlet by the web container at the time it is first called up, means that you won't know the name of the generated Servlet, so you can't call it because you don't know the name and address of that Servlet.

Mark
Get off me! Here, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 801 times.
Similar Threads
Problem while building session with doPost method (at server side)
Help: Potential deadlock in commandAction() ?
How to send bytearray from Servlet to Midlet application?
j2me servlet communication
Exception While connection to webserver
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:26:19.