Meaningless Drivel is fun!*
The moose likes JSP and the fly likes passing data from jsp to servlet using mvc and jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "passing data from jsp to servlet using mvc and jdbc" Watch "passing data from jsp to servlet using mvc and jdbc" New topic
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: 4167
    
  21

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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing data from jsp to servlet using mvc and jdbc
 
Similar Threads
Servlet not able to retrieve the values from jsp form
Checkbox value not being passed to bean.
How to update a image using servlet?
how to manage values of disabled cells in a row to the actionServlet in a loop?
onchange for dynamically added rows