• 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 checkbox's results through JSP in database

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
create dest.jsp



i have this tables on mysql :




and i need from the user to fill the form on the "create dest.jsp " and the data from (country,city,url) to match in Dest table and the checkoboxes results to match in Dest_has_categories on idCategories (in order the values = 1,2,3 to match as foreign key on categories table to winter , christmas,summer)

my create-dest-code .jsp (have some faults on checkboxes for sure):



for example user giving this data to form : Spain,Madrid, "a url" and check max 2 checkboxes that user thinks that madrid belongs , i need now to take the "Spain,madrid,Url" at dest table (i can do it) and take the results of checkboxes on table categories_has_categories on (id category) in order to match with table category as foreign key , so how can i insert the checkboxes results and do these connections with tables?

PS: sorry for my bad syntax...
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There seems to be no question or problem description to go with the code. What kind of help are you looking for?
 
Saloon Keeper
Posts: 15484
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's really bad practice to put processing code in JSP.

You should do all the processing in a Servlet, prepare the necessary information for display, and then forward that to the JSP. The JSP shouldn't do *any* logic.
 
John Vario
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:There seems to be no question or problem description to go with the code. What kind of help are you looking for?




Check above the code !! :D
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jh Var wrote:Check above the code !



What should we check it for - code quality? If the code doesn't do what you think it should do, tell us what it actually does, and what prevents you from making the required changes.
 
John Vario
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:It's really bad practice to put processing code in JSP.

You should do all the processing in a Servlet, prepare the necessary information for display, and then forward that to the JSP. The JSP shouldn't do *any* logic.



yea i know but my exercise says it.. ;(
 
John Vario
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:

Jh Var wrote:Check above the code !



What should we check it for - code quality? If the code doesn't do what you think it should do, tell us what it actually does, and what prevents you from making the required changes.




the second , i am trying to make you understant what i want , and why my code didn't work and how i can chage it right!
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We don't know what the code does - you do. If you don't tell us what happens when you run it, how should we know what to look for? It's much faster for you to describe the problem(s) than for us to guess what it might be.
 
John Vario
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:We don't know what the code does - you do. If you don't tell us what happens when you run it, how should we know what to look for? It's much faster for you to describe the problem(s) than for us to guess what it might be.



this code doesnt run either the two insert on the tables when i run it , it doesnt drops me an error but in database there is no data at both tables...
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the values of id8, id9 and id10?

Print the stack trace if there is a SQLException so you'll know if there is a problem.

You should also print out the values of "sqlString" and "insert" to make sure they are what you think they are.

Also, you should use || rather than | in logical expressions.
 
John Vario
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:What are the values of id8, id9 and id10?

Print the stack trace if there is a SQLException so you'll know if there is a problem.

Also, you should use || rather than | in logical expressions.



if you see my first jsp page tells what is id8 .... i dont know how to print the stack trace...
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Vario wrote:if you see my first jsp page tells what is id8


You said what you entered, but what you need to check is whether the values that you work with in the JSP have actually the values that you think you have. That's what debugging is all about: checking that the assertions you make about the flow through the code, and about the values of variables, are actually true. Usually you'll find that some of them are not what you think they are.

i dont know how to print the stack trace...


That's what line 54 of the JSP does; you need something similar before line 41 (and you should remove lines 38 and 40).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic