• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Problem in delete form

 
Ranch Hand
Posts: 32
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Follow the throw exception
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by it doesnt work ? What exactly is the problem?
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hemant!

I'll try that, change method post to get
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I get solve!
Follow the code

Now, the button update and delete are work normally.
Thanks!
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic