473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get checked boxes parameter into database using Java Servlet?

27
Hi,

I have this form whereby I allow users to checked the number of subjects he is interested.

But, I am stuck when I want to parse the parameters into the database.

Hope someone can advise me how.
<td><h3><b>Subjects Interested :</b></h3></td>
<tr> <th>Lower Primary</th>
<td><input type="checkbox" name="txtsubjects" value="English">English
<input type="checkbox" name="txtsubjects" value="Chinese">Chinese
<input type="checkbox" name="txtsubjects" value="Math">Math
<input type="checkbox" name="txtsubjects" value="Science">Science </td>
[/code]

And my partial code for servlet in which I am stuck.

Expand|Select|Wrap|Line Numbers
  1. strCreateRecordSQL += "(strFullName,strEmail,strAddress,"
  2.                         + " strLocation,  strContact, strType, strSubjects, "
  3.                         + " strFrequency, strTutorspref, stBudget, StrRemarks) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
  4.                 ps = con.prepareStatement(strCreateRecordSQL);
  5.  
  6.  
  7.  
  8.                 ps.setString(1, strFullName); 
  9. /
  10. / I need to assign the parameters here and insert the checked boxes by user into a database i have created but I do not how to go about doing it for more than one checked boxes.
  11.  
  12.  
  13. String strSubjects[] = request.getParameterValues("txtsubjects");
  14.             if (strSubjects !=null)
  15.             {
  16.                 for(int i = 0; i < strSubjects.length; i++)
  17.               {if (i > 0 )
  18.  
  19.               }
  20.             }
  21.  
May 6 '10 #1
0 1314

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil Powell | last post by:
I have a PHP script that will be doing an @fopen file open command to a Java servlet, sending content via a query string. Problem is that it appears the Java servlet does not receive anything...
5
by: SelvaSA | last post by:
Hi All, I can able to create a excel file using POIFS plug-in from Jakarta, but i want open already created file from a selected location. Here i am pasting my code to generate excel file. ...
8
by: menmysql | last post by:
i am not bale to solve this problem since two weeks i am trying to access records from mysql database using jsp. inside this jsp program i wrote all my JDBC code. it is working very nicely and...
2
by: Hatricks | last post by:
Hi, How can I store & retrieve PDF file in SQL 2005 database using java. Any code will be of great help.
0
by: aarthiraaj | last post by:
In my user screen I have view link, if I click this link it will go to servlet and open one word document. It is opening properly, but while opening the attachment it generate one dialog box like...
1
by: sramasami | last post by:
hi im doing the project in image mining... i need a help... how to store the images in the databases.. and how to retrieve those images one by one from databases.. pls help me for this.. i...
2
by: mannavavp | last post by:
hi friends, please let me know how i can store audio files in database table using java programming?
1
by: nina15 | last post by:
Hi, I need to confirm the security of my new system so that this needs to be tested for the XSS attacks. Is there a way that the client can access the server Database specially...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
by: 9664266462 | last post by:
my bean/class page package db; import java.sql.*; public class Topic {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.