B
babyrun
Unregistered / Unconfirmed
GUEST, unregistred user!
/*
该段servlet实现初始化数据的打印输出,页面显示过于简单,我想利用RequestDispatcher的forward方法将其数据传递到一个jsp页面,不知如何处理,请高手指点
*/
public class ShowProduct extends HttpServlet{
public voiddo
Get(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException{
ServletContext con = this.getServletContext();
ArrayList list = (ArrayList)con.getAttribute("catalog"
Iterator it = list.iterator();
PrintWriter out = response.getWriter();
out.println("<html><body>"
out.println("<b>Show Product</b><br>"
while(it.hasNext()){
Product product = (Product)it.next();
out.println(product.getId()+"
"+product.getPrice()+"
"+product.getQuantity()+"
"+product.getDes());
out.println("<br>"
}
out.println("</BODY></html>"
}
}
该段servlet实现初始化数据的打印输出,页面显示过于简单,我想利用RequestDispatcher的forward方法将其数据传递到一个jsp页面,不知如何处理,请高手指点
*/
public class ShowProduct extends HttpServlet{
public voiddo
Get(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException{
ServletContext con = this.getServletContext();
ArrayList list = (ArrayList)con.getAttribute("catalog"
Iterator it = list.iterator();
PrintWriter out = response.getWriter();
out.println("<html><body>"
out.println("<b>Show Product</b><br>"
while(it.hasNext()){
Product product = (Product)it.next();
out.println(product.getId()+"
"+product.getPrice()+"
"+product.getQuantity()+"
"+product.getDes());
out.println("<br>"
}
out.println("</BODY></html>"
}
}