Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Unable to find specific product

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys currently i am using textfield to find the product name from the database and display the specific information. Like for example I type in Reb beanie and if the red beanie exists, it will show the record of it and i am able to click on the product name called reb beanie in order to view the specific detail of it.

I make use if servlet as well as jsp:

This is my servlet


This is my jsp find text field:


And when I type reb beanie in the text field it will show the record of it:


When I click on the product name called :reb beanie, it will go to the specific details of it:

However do you guys know how to change this to correspond prodName?


Thanks you:)
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you should replace this:


with this:
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks:)
Which mean I have to add it like this?





Thanks:D
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP, not JDBC.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A few bits of advice:
  • Watch out, you have one named parameter in your PreparedStatement but you are setting the second parameter to your value
  • Its generally not considered good practice to mix JDBC code into a JSP. Its harder to work in thie environment and it ties your view to your data access code. You could move it into a Bean
  • A small point I know, but Java variable names usually start with a lower case letter. Following conventions makes debugging easier
  • What happens if the request parameter is not there?
  •  
    Loh Peggie
    Ranch Hand
    Posts: 51
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I see i see.Sorry.

    Erm if i want to search either by ProdName or by prodColor is it do like this?



    My servlets is this:



    Thanks:)
     
    Charbel Keyrouz
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    First of all you need to make sure that you have sent the parameters before using the request.getParameter() method.

    here is where you are sending the parameters:


    so if you need to use the ProdColor you need to send it at the same place, as follows:


    I do not know in which index of the arraylist you have put the prodcolor property this is why I have put a ? instead.
    and then in your class or jsp file you can use request.getParameter("ProdColor");

    if you make sure that this part is correct then yes your query will work.
     
    It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic