[Logo]
Forums Register Login
I'm trying to insert data into the database, however it displays "null"
Hi Everyone.....I'm new to programming. Please help me out with this issue.

It is accepting the values however, Database doesn't show the actual given data. displays as "null"

JSP


HTML code
Welcome to CodeRanch!

You say it is accepting the values. Does that mean if you add a print before this line, the four values aren't null?
Welcome to the Ranch!

You really shouldn't be doing any kind of database access in a JSP. If you're following an example from a book, I'd suggest you get another book. That way of programming JSPs was way back in the very early days of Java.

I'm adding this thread to the JSP forum. Sheriff Bear will be around shortly to put you on the right path.
@Jeanne Boyarsky,Junilu Lacar.. Thank you for your reply.

The String values are given in HTMl page. I did not understand why the DB is showing null values. Its my school assignment.
I'm surprised that you are getting records written to the database at all, since that JDBC URL looks wrong to me. But if that code is actually adding rows to the database and the values in the rows are all null, then that inevitably means that your code put the nulls there. Jeanne suggested you should put some debugging code into your JSP to see if that's really the case -- I second that suggestion.
(1 like)
Your input elements are missing a name attribute.  Read-over this explanation of the HTML <input> name attribute.

If you would like to test your HTML form independently of the JSP code, try specifying an action of http://httpbin.org/post in your form.  httpbin is a test site and it will return back informaiton about your request (in JSON format).  What would be interesting for your particular problem is what it returned in the JSON form attribute.

For example - I added another input element to your form.


If I enter Hello HTML in to my new element and submit the form to httpbin, I get this back:

In the form attribute there is one key/value pair: the key is what I specified as the name in my new input element; and the value is what I entered in the my new field in the form.  As you have already know, to get this value in JSP, you would use request.getParameter("another-field-for-testing").

My suggestion: add the missing name attributes to your input elements, test with httpbin until the form is working as expected, then try with your JSP code again.
Good catch Ron!
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 24, 2017 00:54:36.