• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to find specific product

 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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
 
Charbel Keyrouz
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should replace this:


with this:
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
Which mean I have to add it like this?





Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
    • 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
    • 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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic