public class SampleServlet extends HttpServlet {
public void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException,IOException {
response.setCharacterEncoding("Windows-31J");
PrintWriter out = response.getWriter();
out.println("<html><body>");
HttpSession session = request.getSession();
session.setAttribute("KEY01","DATA01");
session.setAttribute("KEY02","DATA02");
session.setAttribute("KEY03","DATA03");
Enumeration e = session.getAttributeNames();
while(e.hasMoreElements()) {
String key = (String)e.nextElement();
out.println( key + ":" + session.getAttribute(key) + "<br>");
}
out.println("</body></html>");
}
}
|