1 package org.apache.velocity.demo.action; 2 3 18 19 import java.util.*; 21 22 import javax.servlet.http.HttpServlet ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 import org.apache.velocity.context.Context; 29 30 import org.apache.velocity.demo.om.*; 32 33 40 public class PostCommand extends Command 41 { 42 public PostCommand( HttpServletRequest req, HttpServletResponse resp ) 43 { 44 super( req, resp ); 45 } 46 47 52 public String exec( Context ctx ) 53 { 54 String name = request.getParameter("name"); 55 String subject = request.getParameter("subject"); 56 String email = request.getParameter("email"); 57 String content = request.getParameter("content"); 58 59 Message message = new Message(); 60 message.setName( name ); 61 message.setSubject( subject ); 62 message.setEmail( email ); 63 message.setContents( content ); 64 65 ForumDatabase.postMessage( message ); 66 67 Object [] list = ForumDatabase.listAll(); 68 69 ctx.put("listall", list ); 70 ctx.put("hasMessages", Boolean.TRUE ); 71 72 return ListCommand.LIST; 73 } 74 } 75 76 | Popular Tags |