• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing data from jsp to servlet using mvc and jdbc

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im currently new in java ee. I need help on how to pass my data from jsp to my servlet to fil up my query. Whenever i run, the error is being catch and i print out the exception. It says java.null.exception.. I couldn't find out where my error is..please help me... thanks..

Here is my code:

UpdateProductServlet.java


and my ProductDao.java



and this is my ProductById.jsp

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any of your form inputs which are disabled do not get submitted, so they never reach the servlet as request parameters. Take out all the disabled attributes for the data you want to show up in the request.

Also you have this in your Servlet for error handling:

That is very bad practice: You should print the exception's message and stack trace to a log file at least, and not just the e.toString() to the page's output. That would help you figure out which parameter is null.
 
Lloyd Liongson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have a button there when the edit button (javascript function)is click, the fields will be enabled allowing user to edit the fields except for the id. then the update button will appear for calling the servlet.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I carefully read your code for servlets and jsp . My point of view null pointer exception error is run time error.

1) In UpdateProductServlet.java , your are not accessing all parameters from jsp page.


you can check all values whether these are coming or not. using followings statement

like as
System.out.println(description);
System.out.println(price);
System.out.println(size);
System.out.println(aisle_id);
System.out.println(id);

If any one above statements will display NULL or null , it means that no value is transfer from jsp to servlet.

 
Lloyd Liongson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi. i have solve the problem, i forgot to include form action in my jsp..
 
reply
    Bookmark Topic Watch Topic
  • New Topic