protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub HttpSession session = request.getSession(); session.setAttribute("account", 1000); response.getWriter().write("your account is "+session.getAttribute("account").toString()); }
getServletContext().setAttribute("wash", 1000);
response.getWriter().write("Servlet1 wash: "+getServletContext().getAttribute("wash").toString());