I was trying to POST a URL to the server but it gives an exception (no NullPointer caught), but the same application works on other mobile perfectly...please, is there any thing I have to do on the application to make it work on the Blackberry?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I was trying to POST a URL to the server but it gives an exception (no NullPointer caught), but the same application works on other mobile perfectly...please, is there any thing I have to do on the application to make it work on the Blackberry?
Look at the code and see why there is NullPointerException. Fix that code so that it works on the device.
this is the method performing the work...its actually giving this kind of error: error 104 No NullPointerException Caught.
private boolean login = false;
private String response = null;
private void login() throws IOException, InterruptedException {
HttpConnection hc = null;
InputStream input = null;
//OutputStream output = null;
try
{
String url = "http://www.mantraa360.com/sefex/payment.php/?vin=" + vinTextField.getString() + "&pin="
+ pinTextField.getString();
//connect to server
hc = ( HttpConnection )Connector.open( url );
hc.setRequestMethod( HttpConnection.GET );
//Authentication
if ( hc.getResponseCode() == HttpConnection.HTTP_OK )
{
login = true;
}//end if
// if ( !login )
// {
// getFailureAlert().setString( "Error..File Not Found" );
// failureAlert.setTimeout(Alert.FOREVER);
// switchDisplayable( failureAlert, sefexLoginForm );
// vinTextField.setString("");
// pinTextField.setString("");
// System.out.println( "Invalid" );
// }
input = hc.openInputStream();
int length = (int)hc.getLength();
byte[] data = new byte[ length ];
if ( input != null )
{
input.read( data, 0, length );
response = new String(data, 0, length);
System.out.println(response);
/* if ( response.startsWith( "P" ) )
{
getSefexRespStringItem().setText( response );
}//end inner if(response.startsWith("P"))
else if ( response.startsWith( "I" ) )
{
getSefexRespStringItem().setText( response );
}//end inner if(response.startsWith("I"))
:
else
sefexRespStringItem.setText( response );
}//end if(input != null)
*/
}
else
return;
input.close();
hc.close();
if ( response.trim().equals( "0" ) )
{
response = "Successfully Credited \n Account No : "+vinTextField.getString();
System.out.println(response);
}//end if
}//end try
finally
{
if ( input != null )
input.close();
if ( hc != null )
hc.close();
}//end finally
What is the its you are talking about? I don't recognize the text of the error messageits actually giving this kind of error:
What variable is null? Why is it null?
Please wrap your posted code in code tags. See:http://www.java-forums.org/misc.php?do=bbcode#code
or Go Advanced and use the # icon
actually, i ran an application on another emulator and a Nokia phone..the application worked perfectly..the application is to POST a url to the server and then get a response....i got my response correctly but when i ran it on the BlackBerry simulator and the mobile itself..it was giving errors....: "App Error 104 Uncaught: NullPointerException Scroll for available commands", that was the error been displayed on the screen..
No ideas on how to debug code on an emulator, simulator or phone.