• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Testing an app for connecting to a servlet.

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Julio C Moreno
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic