• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP --> Servlet --> Bean --> Servlet --> JSP  RSS feed

 
rich werth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Whoops Thank you!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!