I want to insert values from jsp text boxes into my database. I have no clue on how to start. I am using netBeans 5.5 with the derby database(JDBC). My problem is I don't know how to take the varible from the text box and place it in the SQL insert statement. How do I start? for examlpe I have 3 textboxes labeled firstName, lastName, phone. I have the values firstname.value, lastnname.value and phone.value.
I want to send the inforrmation from the textboxes to the database. I really want to go to the bean but was not sure how. This is what I am trying to do. I was going from the submit to a jsp page. At this jsp page I was trying to call use bean to move to the bean. If I place the useBean before the submit in the form on the first jsp I would eliminate the second jsp would that work? I don't have the code after the submit to the jsp.
Originally posted by Donna Bachner: If I place the useBean before the submit in the form on the first jsp I would eliminate the second jsp would that work?
Of course not. The useBean executes on the server long before the page containing the form ever gets sent to the browser.
You really need to take a step back and get a handle on how the technologoes that you are using work. Perhaps this article will help with regard to understanding JSPs.
I don't have the code after the submit to the jsp.
As Jeanne pointed out, you shouldn't be submitting to a JSP. Using JSP for anything other than renderring the HTML view is considered an extremely poor practice. Submit to a servlet to perform your data processing.
Bear, Your link helped tremdously Thats in the end what I have been trying to do. To useBean on the first jsp would cause it to deploy before the submit button. and sending it to the servlet was not working for me either. I just have one last question. How do you use a variable in your sql statement? I have the following sql statement with the varable "name" I have tried this: select * from ADDRESSBOOK WHERE lastName = (name); and select * from ADDRESSBOOK WHERE lastName = ('name'); and select * from ADDRESSBOOK WHERE lastName = (name.value); ;)
Joined: Oct 08, 2004
Prabhu, you are right that is where I want to call the bean(or servlet) to do the JDBC stuff. If I call the servlet from the first JSP I would not need the second correct? can I pass the varibles using what means. I know how to send the information to a bean but not to a servlet. What I need is any way to send the information from the textbox On a JSP to a servlet (or bean) to put the information into a DB. I have tried to use the submit option to send the page to the servlet and that does not work. I also tried useBean
Joined: Oct 08, 2004
I found the answer to my question about how to pass a value from the jsp to the servlet. The only question I have now is how to put the variable value into the SQL is there special syntax. ;)