| Author |
passing data from jsp to servlet using mvc and jdbc
|
Lloyd Liongson
Greenhorn
Joined: Dec 10, 2012
Posts: 3
|
|
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
|
 |
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3041
|
|
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.
|
Steve
|
 |
Lloyd Liongson
Greenhorn
Joined: Dec 10, 2012
Posts: 3
|
|
|
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.
|
 |
sourav jain
Greenhorn
Joined: Nov 19, 2012
Posts: 22
|
|
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
Joined: Dec 10, 2012
Posts: 3
|
|
|
hi. i have solve the problem, i forgot to include form action in my jsp..
|
 |
 |
|
|
subject: passing data from jsp to servlet using mvc and jdbc
|
|
|