What follows isn't based on struts, beans or any more "formal" technique, but it works, and I hope it helps.
I find it most helpful to translate to and from objects and SQL as close to the database as possible. In other words, you might have an object called SkillSet with methods like isJSPSkilled(), isJAVASkilled(), isHTMLSkilled() for querying, and setJSPSkill(), setJAVASkill(), setHTMLSkill() for setting the values. Then, when the user logs in, as you build their profile, you can use an SQL query to set the values in the SkillSet object for this user. Now building the check boxes becomes trivial. In your JSP, retrieve the SkillSet object (from the session, a bean, or as a request attribute - my favorite), and then your JSP would look like // retrieve skill set SkillSet skills = (SkillSet) request.getAttribute("skillset"); ... // display HTML <input type="checkbox" value="JSP" <%= skills.isJSPSkilled() ? "checked" : "" %> > JSP <input type="checkbox" value="JAVA" <%= skills.isJAVASkilled() ? "checked" : "" %> > JAVA <input type="checkbox" value="HTML" <%= skills.isHTMLSkilled() ? "checked" : "" %> > HTML This leaves out a lot of the work needed to set this up, etc., but I hope it gives you a direction to a solution. At 01:02 AM 9/18/2005, kamal adif wrote:
I am trying to do this : when a user login he will be presented with a form that has his skills (he already submited in this form), now he can change his skilles by checking or unchecking the checkboxes and when submit all are saved in a table in a database. table : user_table (userID, username). table : const_skills (skilID , value). table : lookup_skills (lkupID, userID, skilID). My problem here is how to populate checked and unchecked checkboxes from database. Problem 1 :: Let say a user login for the first time (now we have his userID in a session), then he has a form that lists : Please check your skills : checkbox1 JSP checkbox2 JAVA checkbox3 HTML the when he submit the form, only the skills with checkboxes he checked are inserted in the lookup_skills table. My question here is how to construct the checkboxes in the form using the query : select * from const_skills ? in an other word : <input type="checkbox" value= the first skilID from the query, how to test the checked if it's false or true, /> <input type="checkbox" value= the 2nd skilID from the query, how to test the checked if it's false or true, /> .... Problem 2 :: Next time the user will login he will see in the form all the skills and his skills are checkec. Please help me. =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com
=========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com