For a simple string
request.setAttribute("foo", "Real's HowTo");
A parameter received by the first servlet to the second one
String requestVar = request.getParameter("sitename");
request.setAttribute("foo", requestVar);
A Bean
MyBean myBean = new MyBean();
myBean.setFooProperty("Real's HowTo");
request.setAttribute("foo", myBean);
Then you forward the request
RequestDispatcher dispatch = request.getRequestDispatcher("next.jsp");
dispatch.forward(request, response);
Written and compiled by Réal Gagnon ©1998-2005
[ home ]