• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP and Database

 
zeiffelz zeiffelz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am a newbie in doing jsp in doing a shopping website. Right now, I have an image which has a link to another page (e.g. search.jpg). What I want to implement is that when i click on the image(which is a category), it will link to search.jsp and display all the products in that category from my database. May I know what is the code needed to do that? Thank you!!
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can have your image call a servlet or submit a form (if the image is within form tags) which will call a servlet. Let your servlet use the parameter sent in to call some business logic which does the database access, this will return the results to your servlet/controller, which can then forward it to the appropriate JSP for display. This may require a little bit of reading and redisigning on your part, but it's the most appropriatre way to achieve what you described. Searching and reading up on the MVC pattern will definitely help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"zeiffelz zeiffelz",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!