aspose file tools*
The moose likes JDBC and the fly likes Unable to find specific product Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Unable to find specific product" Watch "Unable to find specific product" New topic
Author

Unable to find specific product

Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Posts: 51
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

Joined: Jun 10, 2005
Posts: 46
you should replace this:


with this:
Loh Peggie
Ranch Hand

Joined: Jul 09, 2009
Posts: 51
Thanks
Which mean I have to add it like this?





Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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?


  • JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Loh Peggie
    Ranch Hand

    Joined: Jul 09, 2009
    Posts: 51
    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

    Joined: Jun 10, 2005
    Posts: 46
    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Unable to find specific product