This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I'm new to jsp world so I want some help...is very important to me so I will explain it in details
I have a jsp which display a form to be filled out. I have some text fields where the user fills them and submit the form. The form next is passed to a jsp page where I'm using some beans, setProperties to save the data to database.
Now my problem is: I want to add in my form a part where the user can add a book. A book may have author,title,edition,publisher. If it was to provide to fill only one book this it could be easy done by having the appropriate text fields and then in process jsp to get the approprite parameters and save the data into database.
I want to add more than one book. I want to have a button let say which it will give the chance to the user to enter the first book and next as many times the button is click to add as many books. (My Idea...)Shall I have to create another form inside the main and each time the button is click to create subforms.
How is this can be done... which mechanism... any reference?
Originally posted by panayiotis panayiotou: The form next is passed to a jsp page where I'm using some beans, setProperties to save the data to database.
This is not a good practice. Modern web applications do not use JSPs for data processing. Rather, your form should submit to a servlet that handles the data processing and delegates the database functions off to Java classes that have nothing to do with the UI.
I think I understand your challenge. If your jsp page is used to imput two different things (e.g user info in the first part and book info in the second part; then you need two javabeans, each updating it's own database table. Set up a unique key for the user and include that unique user key for each book the user adds to the database, that way you can perform a multi table query using based on the key, to retrieve the user and all the books he added to the database table.