This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes Delete doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Delete doubt" Watch "Delete doubt" New topic
Author

Delete doubt

Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
Hello Ranchers!!
I'm new to java ranch!! here i'm doing some database project in jsp and oracle!! i'm planning to do some administrative privilage ie., only the administrator can edit or delete some datas in the database.. the edit is successful.. but the delete is making me problems..

i've created a jsp page..
in that page.. there is a table...
the first column.. is a check box..
the second column is the record from database
and so on up to 10th column..
_____________________________________________________________________
| check |col1 | col2 |col3 | col4 |
|---------------------------------------------------------------------
| | | | | |
| | | | | |
| | | | | |
|____________________________________________________________________

so.. the datas are displaying like this in the jsp page..
if i want to delete the first and the 5th record..
i check the check box corresponding to that!!

int the check box name.. i'm giving the value for search query!!
like file number!!
and it is passing to another jsp page when i press submit...and deletion takes place..
how can i do that!!

please help ranchers..


if u got the idea..and if u have the code please send me!!
thanks in advance!!
regards megha
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
give same name to all your checkboxes


inside your servlet try

String id[] = request.getParameterValues("recordId");

id array will hold all the selected checkbox values.. this is what i remember at the top of my head.. hope it helps !

Thanks,
Rajeev.
Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
Hello Rajeev!!
Thank u for replying me.. with some good ideas!!
ok.. we can delete using the row id of the table

but how to get the row id

just i'm giving the query like this

if there is any problem please let me know!!
_____________________________________________________________________
tab1.append("select rowid from details");

String query = tab1.toString();
out.println(query);

Statement stmt = dbCon.createStatement();
ResultSet rs = stmt.executeQuery(query);


while(rs.next())
{ String rowvalue = rs.getrowid();
//how can i get?
}
________________________________________________________________________thanks in advance

regards
Megha!!
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Hello Megha..
i'm also looking for the same doubt...
if we can get the row id..
then we can particularly delete the row with that row id na

but i don't think it is possible..
y can't u got for a primary key in the table.. i think that may be easier for deleting!! know!!
Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
Hello Aravind!!
But when i created the table i left to give the primary key.. and now abt 100 records are there.. so... if i want to delete one there is duplication orruring.. thatz why.. i need to get the row id..

can any one in the ranchers please help me.. how to get the row id from oracle table

i can execute the query..
select rowid from the table
but i cannot the the values.. from that
for that what should i do!!
i think it is a string value..
we cannot also use.. Result set.. since that is not in the table..
so if u know please help me!!


thanks u..
Regards
Megha
Shekhar Singh
Greenhorn

Joined: Mar 23, 2006
Posts: 1
Originally posted by Megha Rajeevan:
Hello Medha.

use "select rowid,f1,..fn" query and assign rowid value to checkbox id..
regards
Shekhar
Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
Thanks to u very much

thank u ....
i got the answer and i love java ranch forum!!

thank u all ranchers

Megha Rajeevan
Greenhorn

Joined: Mar 22, 2006
Posts: 24
Hello Ranchers!!

Help me please

i'm getting all the values to the jsp page

i'm using request.getParamterValues("test") where test is the checkbox name

String test[] = request.getParameterValues("test");

for(int i=0;i<= test.length();i++)
{out.println(test[i]);
}
but when i give the test.length()
it is showing error!!

how can i fix this problem

thank u ranchers!!
Manu Dhanda
Greenhorn

Joined: Jan 28, 2006
Posts: 23
Hi Megha..


test is an array here. check out your length method here.


"Books are as useful to a stupid person <br />As a mirror is useful to a blind person." <br /> <br />Chanakya quotes (Indian politician, strategist and writer, 350 BC-275BC)
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Originally posted by Megha Rajeevan:
Hello Ranchers!!

Help me please

i'm getting all the values to the jsp page

i'm using request.getParamterValues("test") where test is the checkbox name

String test[] = request.getParameterValues("test");

for(int i=0;i<= test.length();i++)
{out.println(test[i]);
}
but when i give the test.length()
it is showing error!!

how can i fix this problem

thank u ranchers!!


use test.length instead instead.

i think if u can assign the checkbox name as chkBox_DatabaseColmnValue
DatabaseColmnValue should be in java expression.

while getting in the Servlet with getParameterNames() it will return the control names trim of the control name and get the DatabaseColmnValue and pass to the db ...


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Delete doubt