the code is this:
what may be the problem?
Problem #2: id is likely null.
(Problem #3 is creating connections in the web layer rather than the model -- but that's another topic.)
Also you never answered my questions about putting the code in a JSP. Is this an old legacy page, or new code?
i am new in jsp and i dont know how to work with servlets. i need to do a school project, that's why i am usin jsp
laura xhaferaj wrote:i need to do a school project, that's why i am usin jsp
That's the sort of thing you should let us know up-front. Otherwise, we think you are doing real code and will wonder why you are doing things the way that you are.
For the future, be aware that putting Java code into a JSP is akin to trying to use vacuum tubes in a TV set.
The error message is clearly stating that null is being passed to parseInt(). I would suggest putting a logging statement into the code to verify this.
That will emit a line to the console that you can inspect and see what actual value the JSP thinks it has.
By the way, using id to represent the string version, and ID to represent the numeric version is a bad, bad idea. It's confusing at best, and starting a variable name with a capital letter defies convention.
Choose better names.
17: String id = request.getParameter("id");
18: System.out.println("The value of id is " + id);
19: int ID = Integer.parseInt(id);
Error is the same. And nothing else is shown. i don't understand why it doesn't work now, i made an other project before and it was executed without any error and now not :/
laura xhaferaj wrote:Error is the same.
Of course it is. Logging isn't going to change the value. It's still null.
And nothing else is shown.
Then you're not looking in the right place. What OS and server are you using? If Windows and Tomcat, the output will appear in the DOS console window for Tomcat. If you're using a real OS, it'll be in Tomcat's catalina.out file, which you can tail.
i don't understand why it doesn't work now, i made an other project before and it was executed without any error and now not :/
Obviously something is awry. Verifying that you have a null there is the 1st step to finding out why.