1 package example; 2 3 import java.util.List ; 4 import javax.servlet.http.*; 5 import org.apache.struts.action.*; 6 7 8 public class AddAction extends GuestbookAction { 9 10 public ActionForward execute( 11 ActionMapping mapping, 12 ActionForm form, 13 HttpServletRequest req, 14 HttpServletResponse resp) throws Exception { 15 16 GuestbookEntryForm f = (GuestbookEntryForm) form; 17 List guestbook = getGuestbook(); 18 synchronized (guestbook) { 19 guestbook.add(0, new GuestbookEntry( 20 f.getName(), f.getEmail(), f.getMessage())); 21 } 22 23 return mapping.findForward("success"); 24 } 25 26 } 27 | Popular Tags |