• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

insert checked checkbox into table

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys

i am preparing a page on which i have used select & checkbox i need now that those all checkbox whicch a re checked their data should be entered into the new table

the checked checkboxes are to be printed on next page which i am getting printed correctly now i ant to insert it into table but as they all are printed through for loop so when i try to insert them into an array they all are either lost or might not be getting properly

Help me to solve this problem

thank you
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

they all are either lost or might not be getting properly



What exactly do you mean by this? Could you please show your code, and highlight where the problem is?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Swastik for your prompt reply

actually i am checking some checkbox on one page & printing them on another page jsp only

now i need that those checkboxes which are printed are also to be inserted into Postgre SQL table

" I am sorry for inserting my connections in jsp"
my code is :-
one.jsp


two.jsp



thank you if you still cant understand my problem still let me kno please
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would like to tell you one more thing i am selecteing many checkbox at a time
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understood about sections, that multiple sections can be selected. How about division? Can multiple divisions be selected too? If yes, how do you identify which section comes under which division?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for the reply actually i am selecting oly one division under which there are many sections so division is in combo & sections are in chckbox both retrieved from database

thats why i need one division which i can retrieve easily & getting it correctly in my table as i am trying

but the main problem is in sections

looking forward for your reply
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made few changes in page2, kindly have a look. I don't have any way to test. Please do keep backup of your existing code.

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your code but there are some problems in this

1)




Syntax error, parameterized types are only available if source
level is 1.5

2)


cannot convert from object to string

i canot understand these errors please help me i think i am usingstruts 1.3 so thats why 1st error is coming

2nd can be solved
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have solved 2nd problem nw 1st is the remaining one
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
atlast i found changes that i have to make thanks

let me check if code works or not
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was just rechecking the logic, we can probably do it without the iterator too.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i cant say anything about code now is it right or not but there two things more

1) i need to insert one more column where i have writen heillo there is one more column retrieved from database ho wto do that please help me


2) it is not inserting into the table my query is right but still it is not inserting

any clue why so is happening
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can that be done because i cannot understand this logic this is a little bit tough for me

thank you
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



rst=s.executeQuery("SELECT sec_code from sec_code where sec_name='"+sec+"'");
Just make sure the field name sec_code is correct, because I don't have any idea about your table design.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just change this line

to
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the updated code swastik but problem still exists

i have checked my table too

its not insering data into table

2) how to insert onemore clumn after retrieving it form seccode
please help me

thanks for your help till now
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
out.println("Number of records inserted="+updateCount);

What does it print in the above line?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no swastik its not printing anything i think please consider your this code without iterator once again


thank you
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i found that program is not entering if(rst.next)
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rst=s.executeQuery("SELECT sec_code from sec_code where sec_name='"+sec+"'");

Are you sure about the field name and table name in the above query?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup swastik i amm definitely sure about them they all are correct
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I asked only because your query had select *. Not entering into that rst.next(), means its somehow failing to execute the query, or it's failing to find any matching record. Now the only way seems for resolving the issue is to surround the entire scripelet code in try, catch. Print the exception and see what it says. Also put one else condition for that if(rs.next()) and put some message to see where the control is going.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now i have even changed the name of table but still its not working have a look at new code please



thank you once again
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have used both else & try & catch


now its printing else condition

means not entering the if condition

thank you
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey swastik i have tried everyu possible combination of try & catch but ist not going into catch means no exception

every tym it goes into else part
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In page1 the checkbox value is a probably a combination of the section code and section name.



But in page2 you are comparing with the section name

Now consider the value displayed in page1 is 1Section1

But while comparing in page2
the query becomes something like sec_name='<table><tr><td>1</td><td>Section1</td></tr>', isn't it wrong?
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You just print sec and see what you get

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey swastik can you tell me any wy so that i can retrieve sec_code from previous page i.e one.jsp but only those sec_code which are checked

i think the problem is might be due to it cannot match sec_name as it is string


"sec" printing correct values what it should print

thank you
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have changed this code what you have said but still its giving error

i have done it now



now its should give right answer but still not proper reply
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It won't because the value still has that <table><tr> things, and when you retrieve it using getParameter, it gets the complete <table><tr>tags in the variable, and only because of that you are viewing the rendered content in a tabular format.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Considering your last made change in page1, try this once again in page2

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much Swastik
this is working perfectly
i just removed table tag & running so gud

thank you so so much
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic