protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession session = req.getSession(true);
Stateful bean = (Stateful) session.getAttribute("bean");
if (bean == null) {
try {
bean = new LocalEJBDirectory("stateful").lookupStateful(StatefulBean.class, Stateful.class);
} catch (NamingException e) {
throw new ServletException(e);
}
}
resp.setHeader("count", String.valueOf(bean.increment()));