Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in delete form

 
William Flores
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Flores
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's important information that you should have included in the first post. In fact, please post the exact stack trace.
 
William Flores
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Follow the throw exception
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by it doesnt work ? What exactly is the problem?
 
Hemant Thard
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hemant!

I'll try that, change method post to get
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I get solve!
Follow the code

Now, the button update and delete are work normally.
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic