| Author |
Problem in delete form
|
William Flores
Greenhorn
Joined: Dec 14, 2011
Posts: 25
|
|
Hi guys!
I'm with a problem here.
I have a form, and this form has two buttons "UPDATE" and "DELETE". The button "UPDATE" works normally, but the button "DELETE" isn't works.
In my Servlet, I noticed the parameter is comming null.
I didn't understand what's happening, because the button update works normally.
Please anyone help me?
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
What have you done to debug this?
Have you determined what's being submitted as part of the request when the form is submitted? Debug tools in the browser can show you the details of the request.
Have you determined if the conditional check is passing or not? And if not, what's it being compared against that causes it to not work as expected?
This is are just the first of the debugging steps you should take.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
William Flores
Greenhorn
Joined: Dec 14, 2011
Posts: 25
|
|
Hi Bear!
I debug, so when I click on the button delete it passing to Servlet, but when it arrives on "Integer ca = Integer.parseInt(request.getParameter("cmpCa"))" is throw a exception saying it's null.
Do you understand me?
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
|
That's important information that you should have included in the first post. In fact, please post the exact stack trace.
|
 |
William Flores
Greenhorn
Joined: Dec 14, 2011
Posts: 25
|
|
Follow the throw exception
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
OK, this line:
at br.com.sistemaunicid.controller.ServletTutoria.doPost(ServletTutoria.java:109)
tells you where to look.
What's at that line, and under what conditions can it result in a NumberFormatException?
Once you've figured that out, back-track to find out how this condition could possibly arise.
|
 |
William Flores
Greenhorn
Joined: Dec 14, 2011
Posts: 25
|
|
So Bear, I did a test. I changed the form between update and delete.
See below.
Now the button delete works normally, however the button update doesn't works.
This is odd!
|
 |
Vic Hood
Ranch Hand
Joined: Jan 05, 2011
Posts: 474
|
|
|
What do you mean by it doesnt work ? What exactly is the problem?
|
Learning and Learning!-- Java all the way!
|
 |
Hemant Thard
Ranch Hand
Joined: Dec 23, 2008
Posts: 113
|
|
HI William,
I don't see any tag with name "cmpCa" on your JSP page. That's why you are getting null for when you try to search for "cmpCa" on request object.
Now the button delete works normally, however the button update doesn't works.
Yes it should wok because it doesn't execute the following condition :
Normally what i will do for debugging is to change the form method from post to get in jsp to check the parameter and value that are to my service method. I would suggest the same for you to check for the presence of any parameter with name "cmpCa".
Regards,
Hemant
|
 |
William Flores
Greenhorn
Joined: Dec 14, 2011
Posts: 25
|
|
Hi Hemant!
I'll try that, change method post to get
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
|
There is no need to change the method to GET to check the HTTP parameters. All modern browsers have built-in debugging tools that can be used to inspect the network traffic without resorting to changing the code.
|
 |
William Flores
Greenhorn
Joined: Dec 14, 2011
Posts: 25
|
|
Hi!
I get solve!
Follow the code
Now, the button update and delete are work normally.
Thanks!
|
 |
 |
|
|
subject: Problem in delete form
|
|
|