The int type has no .equals method. Even if it did, an int would never have a value of " ".

Be careful not to confuse "" with " ". One is an empty string. the other is a single blank character.

Since null, "", and " " would never be valid values for an int, you'll need to test for these possibilities before trying to convert the parameters from Strings to ints. [ April 05, 2007: Message edited by: Ben Souther ]

Originally posted by Jack Bolton: the variables a and b are declared in the jsp file, they are ints.

so you are suggesting me to do the "if", with the getParameter and equals and then i do the conversion to do the sum?

[ April 05, 2007: Message edited by: Jack Bolton ]

You will want to validate the values before you try to convert them to ints. Another approach is to wrap the call to parseInt in a try catch block and catch the NumberFormatException (NFE) that will be thrown if the parameter values can not be converted to ints. This will also cover you against someone typing "Jack" into one of the fields.

Another approach.... Starting with version 1.4, Java now has good support for regular expressions. This makes it pretty easy to write an isInt(String) method that doesn't require a try/catch block.

First of all, all this code should be in a Java class rather in a JSP. It'd be a lot easier to debug that way as well as following accepted practices.

But that said, why are you putting <% %> around each an every line rather than around the whole Java block? It's making your code even harder to read than it should be and is hiding the syntax errors from you. [ April 05, 2007: Message edited by: Bear Bibeault ]

Herman NB: -I don't understand why you check the parameter 'numero1' twice in one line -jsp's are meant for View, not for logic, but if you really want to put all this Java code into your page, you don't have to put <% %> in every line, once is enough: