File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fetch only checked data

 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am retrieving data in the table from the database with the help of jsp servlet , having check box in each row and i want that only checked should be fetch to another page when i click on save button.
please give me some idea howncan i do this , i don't want to delete any data from the database.
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get IDs for the checked items, yes? So a SELECT with a WHERE IN seeMs like it would do the job.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:You can get IDs for the checked items, yes? So a SELECT with a WHERE IN seeMs like it would do the job.

but that i have to use when i am selecting from database but here i have to select from the page only without changing anything in database.
i mean i have to call a function on "onclick " event which will going select only checked data and what should be the syntax for that , i want that because i have to apply any functionality which will going to sort data from the database on the page and then redirect me to another page which will going to show those selected data.
 
Eshwin Sukhdeve
Ranch Hand
Posts: 90
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

now when i am trying to redirect my data to next page in the table form it is not redirecting, it is redirecting in the url but ii have to redirect in the table form how should i do that.
 
Dhaval J. Patel
Ranch Hand
Posts: 90
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what i assume is that you already have fetched data from the database and created a jsp where the user can check what he/she wants. The next step would be something similar. Just with one little step before it.

1)Send the list of id's to a servlet as shown in the link eshwin provided. Get all the ids from the request parameters in the servlet. I am not sure if you have all the initial data in the session already, but if you dont then query the database again as greg said, SELECT data WHERE id in (<insert all ids you got from servlet parameters>).
2) You will then have all the selected data with you. Create a jsp setting up the format in which you want to display the selected data. Forward the request to a jsp with data in request attributes or session attributes, where inside the JSP iterate over all the data using jstl.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhaval J. Patel wrote:So what i assume is that you already have fetched data from the database and created a jsp where the user can check what he/she wants. The next step would be something similar. Just with one little step before it.

1)Send the list of id's to a servlet as shown in the link eshwin provided. Get all the ids from the request parameters in the servlet. I am not sure if you have all the initial data in the session already, but if you dont then query the database again as greg said, SELECT data WHERE id in (<insert all ids you got from servlet parameters>).
2) You will then have all the selected data with you. Create a jsp setting up the format in which you want to display the selected data. Forward the request to a jsp with data in request attributes or session attributes, where inside the JSP iterate over all the data using jstl.

about which ids you are talking, the fields of database or the checkbox id.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Megha Singhal wrote:
Dhaval J. Patel wrote:So what i assume is that you already have fetched data from the database and created a jsp where the user can check what he/she wants. The next step would be something similar. Just with one little step before it.

1)Send the list of id's to a servlet as shown in the link eshwin provided. Get all the ids from the request parameters in the servlet. I am not sure if you have all the initial data in the session already, but if you dont then query the database again as greg said, SELECT data WHERE id in (<insert all ids you got from servlet parameters>).
2) You will then have all the selected data with you. Create a jsp setting up the format in which you want to display the selected data. Forward the request to a jsp with data in request attributes or session attributes, where inside the JSP iterate over all the data using jstl.

about which ids you are talking, the fields of database or the checkbox id.


also i can't use jstl because jstl is not enabled in my college server.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't need to be enabled by the server. You can just use it in your own web app by dropping the jar files in WEB-INF/lib and using the taglib directives on the views.
 
Dhaval J. Patel
Ranch Hand
Posts: 90
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Megha Singhal wrote: about which ids you are talking, the fields of database or the checkbox id.


Its up to you really. Your final aim is to get correct data. Ids you use should be consistent. You cant use random ids for checkbox and then use those ids to query the database, it wont get you the right data and it makes no sense.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhaval J. Patel wrote:
Megha Singhal wrote: about which ids you are talking, the fields of database or the checkbox id.


Its up to you really. Your final aim is to get correct data. Ids you use should be consistent. You cant use random ids for checkbox and then use those ids to query the database, it wont get you the right data and it makes no sense.


there is some changes in my requirement , now i want that i am fetching data from the database with corresponding checkboxes in each row but as i am not fetching that into any text boxes so is there any way that i can able to insert only checked data on submission.
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have hidden text field which contains selected item from the list/drop down box and extract value from it when being submitted. This is a simpler idea.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumaravadivel Subramani wrote:Have hidden text field which contains selected item from the list/drop down box and extract value from it when being submitted. This is a simpler idea.


i didn't get what you are saying
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have an input text field and populate selection value from list/drop down box it when the selection happens, so that when you submit it later and extract as form element in server/where ever needed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic