File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problem in delete form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in delete form" Watch "Problem in delete form" New topic
Author

Problem in delete form

William Flores
Ranch Hand

Joined: Dec 14, 2011
Posts: 30

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

Joined: Jan 10, 2002
Posts: 61773
    
  67

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William Flores
Ranch Hand

Joined: Dec 14, 2011
Posts: 30

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

Joined: Jan 10, 2002
Posts: 61773
    
  67

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

Joined: Dec 14, 2011
Posts: 30

Follow the throw exception
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61773
    
  67

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

Joined: Dec 14, 2011
Posts: 30

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: 477

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: 122
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

Joined: Dec 14, 2011
Posts: 30

Hi Hemant!

I'll try that, change method post to get
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61773
    
  67

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

Joined: Dec 14, 2011
Posts: 30

Hi!

I get solve!
Follow the code

Now, the button update and delete are work normally.
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in delete form