システムに挿入された新しいエントリのリストを表示する JSP ページがあります。
私の myApplication.jsp は次のように構成されています。
A list of entries in the system
A form with textboxes that submits new entries.
JSP がサブミットすると、次の処理を行うサーブレット クラスが呼び出されます。
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String author = checkNull(req.getParameter("author"));
String service = checkNull(req.getParameter("service"));
Dao.INSTANCE.add(author, service);
resp.sendRedirect("/myApplication.jsp");
}
私の Dao.Add は次のようになります。
public void add(String author,String service) {
synchronized (this) {
EntityManager em = EMFService.get().createEntityManager();
Shortly shortly = new Shortly(author, service);
em.persist(shortly);
em.close();
}
}
私が抱えている問題は、にリダイレクトされたときにmyApplication.jsp
、追加した新しいエントリがリストに表示されないことです。ページを更新すると、表示されます。