This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes html radio button add to database Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply 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: 56180
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56180
    
  13

Maybe this article can help? It explains how data flows in moderne web applications.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: html radio button add to database
 
Similar Threads
Comparing value of radio button against answer from the database
Reading Radio Button values
Problem in Login page
Radio Button,Check Boxes
How can I catch the radio button action in jsp?