Java/jsp problem

Discussion in 'OT Technology' started by fatlip, Jan 11, 2003.

  1. fatlip

    fatlip Transcendence Into The Peripheral

    Jun 16, 2001
    Likes Received:
    Hey guys, I’ve been learning java for a while now and just recently decided to learn about the java enterprise side of things. I’m trying to build a simple e-commerce site, using jsp, servlets and ejb’s, but I’ve encountered what is most probably a simple problem. Basically, I want to have a HTML navigation menu, which consists of the various product categories, by clicking on a category the user is forwarded to a jsp page that queries my stock database for items that belong to that category. The problem is, when a link is clicked on the HTML menu, how do I pass the relevent category (in the form of a string or something) to the jsp page so that it can use it to query the database? Would I have to use a bean or could I pass the info via the link from the menu?

    Thanks in advance. :bigthumb:
  2. CompiledMonkey

    CompiledMonkey New Member

    Oct 26, 2001
    Likes Received:
    Richmond, VA
    You could do a few things. Your best option would be to send a get to a servlet. Pass which parameter you need in the url and you can process your action within the servlet. Your hyperlink should look something like this...

    Make sure the nameOfServlet matches what you have in your web.xml file.

    Also, if this was a form you would send the action from the form to a servlet via a post. Then you would call the getParameter method from your request object for the parameters in your form. After you've gotten those, you would be able to process your action in the servlet.

    One last note, I would stay away from EJBs while you begin. Get the hang of jsps and servlets first. Come back in a month or so and add EJBs to the mix. Mainly because you go into a whole new world of required servers. You'll need a true application server to run EJBs. If you are just using JSPs and Servlets you can use an opensource product in Tomcat. Good luck. :)

Share This Page