• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP --> Servlet --> Bean --> Servlet --> JSP

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1st Is that the right way to go and 2nd
I query in the bean and am able to get the resultSet back to the servlet but not back to a jsp page.
Here is what I have so far.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String tableName = "";
try {
tableName = request.getParameter("table");
db.setTable(tableName);
db.connect();
rs=db.viewItems();
request.setAttribute("theResult", rs);
}
catch(Exception e) {
e.printStackTrace();
}
ServletContext sc = getServletContext();
String url = "/loop.jsp";
RequestDispatcher rd = sc.getRequestDispatcher(url);
request.setAttribute("theResult", joe);
rd.forward(request, response);
}

Can someOne please show me where I'm going wrong. I have looked in a few books and a few webSites but I haven't seemed to find any examples of this.
Any help is greatly apreciated
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Uh... It appears that you are overwriting the result set (previously added to the HttpRequest with the name "theResult") with the value of an (undeclared?) variable named "joe".
The HttpRequest is exactly like a HashMap. You can only have one value for each key.
Kyle
 
rich werth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoops Thank you!
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic