public class SampleServlet extends HttpServlet {
public void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException,IOException {
request.setAttribute("data1","request-data1");
request.setAttribute("data2","request-data2");
response.setContentType("text/html;charset=Windows-31J");
PrintWriter out = response.getWriter();
out.println("<html><body>");
Enumeration e = request.getAttributeNames();
while( e.hasMoreElements() ) {
String name = (String) e.nextElement();
out.println(name + "=" + request.getAttribute( name ) + "<br>");
}
out.println("</body></html>");
}
}
|