473,417 Members | 1,623 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,417 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 1318

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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.