permaculture playing cards*
The moose likes JSP and the fly likes html radio button add to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "html radio button add to database" Watch "html radio button add to database" New topic
Author

html radio button add to database

bhavin ragha
Greenhorn

Joined: Mar 28, 2012
Posts: 17
I have a html radio button. When the user clicks the submit button, I want the value to be added to a database table.

there are the 4 radio buttons

o a
o b
o c
o d

--- I have used request.getParameter() and I have quoted q1. but when I check to see what is in the database table "null" is added. How do I add the value in the database?

here is my html radio buttons.


... here I am trying to add the value in the table.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Step 1: refactor your HTML code to use lowercase rather than all uppercase. That style of HTML went out in 1998 and is rather unreadable. This won't do anything to solve your issue, but it will make your code more readable and more likely to get you help.

Step 2: Change your form action to submit to a servlet not a JSP. Then move your database code to the servlet. JSPs should not me mis-used in this way, JSPs are for creating views, not for processing form input, and certainly not for performing database access.

Step 3: Once you've done all that, post back with any errors you are seeing in the logs, and an exact description of what is happening. See the FAQ ItDoesntWorkIsUseless (that's a link) for instructions on what information to include.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
bhavin ragha
Greenhorn

Joined: Mar 28, 2012
Posts: 17
ok it worked... and i have made all the changes you said... the data is added in the table... but now i want it to be taken to another jsp bot i dont want to put a url link.

question1.jsp ---> question1.java (servlet) ---> question2 ----> question2.java (servlet) there are 5 questions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Maybe this article can help? It explains how data flows in moderne web applications.
 
GeeCON Prague 2014
 
subject: html radio button add to database