0

I found this link...

Java:how to pass value from class/bean to servlet

I tried it and it works (thanks to BalusC) This was very helpful and answers all my questions that I've been researching for several days now.

However I'm trying to figure our how to pass the parameter from JSP to the sql query in DAO

if for example I want to create a jsp form to filter the result that the servlet will be producing...

Thanks in advance

Community
  • 1
  • 1
toink
  • 255
  • 4
  • 11
  • 30

1 Answers1

1

It depends on how do you want to invoke DAO methods, (please clarify it):

  1. If you want to call DAO methods directly from your JSP (which is a bad practice), I recommend using JSTL's SQL tag library.
  2. If you want you can develop your custom tag-library to invoke your DAOs.
  3. If you are invoking DAO methods from a Servlet (or using an MVC framework), you cant use request.getParameter(paramName) to get what user have filled in the inputs, then call the DAO methods, and set the result of DAO in request attributes.
Amir Pashazadeh
  • 7,170
  • 3
  • 39
  • 69
  • hello amir.. thanks very much... I have now a table containing all the list of data.. however I want to filter the results in the list.. example.. www.example.com?parameter=value – toink Mar 16 '12 at 15:16
  • i think it is more on the number 3 – toink Mar 16 '12 at 15:18
  • sorry for my ignorance.. I'm still trying to learn things up.. I have a post in DANIweb which has my codes. here's the link ---> http://www.daniweb.com/web-development/jsp/threads/417930 – toink Mar 16 '12 at 16:19
  • I can get list all the data however... I'm thinking on how I can filter the results using a form or a link – toink Mar 16 '12 at 16:20
  • 1
    Just change the DAO's method signature, to accept some parameters (which are used for filtering data) and then pass that parameters in servlet's `doGet` method – Amir Pashazadeh Mar 17 '12 at 04:31