I have a JSP page that shows a list of new entries inserted on the system.
My myApplication.jsp is structured like this:
A list of entries in the system
A form with textboxes that submits new entries.
When my JSP submits, it calls my servlet class that does:
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");
}
My Dao.Add looks like this:
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();
}
}
The problem that I'm having is that when I get redirected back into myApplication.jsp
, the list does not show the new entry I added.
When I refresh the page, then it shows.