Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to select using check box

 
roy ramos
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i attached my code which is actually not sure how to do what i need to do, im only new in programming still learning hope somebody will guide me on this

ok what i need to do is to list all student in the student table then using check boxes select student that need to create for year 2010 in the student_ongoing table

 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this code showing your students?
 
roy ramos
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes sir
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now you want to select some students and add them to some table in some database, is that so? I think you only have to put this inside a form and submit it to the server, then in the servlet you get the values and in the Data Access Class you do the database operations. By the way you should always do something like this, not coding java directly in the JSP, and definitly not doing the SQLs in the JSP, have a look at the Model View Controller: http://java.sun.com/blueprints/patterns/MVC.html

 
roy ramos
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir Albareto,

Actually im just starting reading that and since i'm just a newbie im a bit blur perhaps you can help me by showing some code, if possible
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically what MVC means is that in the JSP you only show things and there you call the Servlet, which interpretate the data and send it to other classes which have the logic of the applicacion, as you are learning I think is good to learn correctly how to do things and putting all the logic in the JSP is not the best way. Take a look to the tutorials and documentation: http://java.sun.com/javaee/5/docs/tutorial/doc/bnadr.html

But going back to your problem, how do you want the students to be inserted in the database? Is the first thing you have to decide. At this point you have a screen with some students and checkboxes but how are you going to tell the applicacion which students are going to be inserted in the table? You need a button or a link or whatever to submit the data...
 
roy ramos
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,

actually this code have a submit button to post on the servlet i only removed because im not sure how do to once im already in the servlet, how to retrieved all selected student using check boxes and save mutliple data in the table
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet receives data from the request and send it through the response

Have a look to the API, specially to this method of the ServletRequest interface:

http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterValues%28java.lang.String%29
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic