1 import java.io.*; 2 import java.util.*; 3 import javax.servlet.*; 4 import javax.servlet.http.*; 5 6 import beans.FooFormBean; 7 import jodd.bean.BeanUtil; 8 import jodd.servlet.*; 9 10 public class ReadForm extends ActionServlet { 11 12 public void doRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { 13 System.out.println("\n\n>form submited"); 14 FooFormBean ffb = new FooFormBean(); 15 16 System.out.println(">load form bean from the request"); 17 System.out.println(">bean init:"); 18 System.out.println(BeanUtil.toString(ffb)); 19 20 System.out.println(">request:"); 21 Enumeration paramNames = request.getParameterNames(); 22 while (paramNames.hasMoreElements()) { 23 String paramName = (String) paramNames.nextElement(); 24 System.out.println("---parameter: " + paramName); 25 String[] paramValues = request.getParameterValues(paramName); 26 System.out.println("values:"); 27 for (int i = 0; i < paramValues.length; i++) { 28 System.out.println(paramValues[i]); 29 } 30 } 31 32 BeanUtil.load(ffb, request); 33 System.out.println(">bean loaded:"); 34 System.out.println(BeanUtil.toString(ffb)); 35 36 HttpSession session = request.getSession(); 37 session.setAttribute("bean", ffb); 38 forward(request, response, "form1-res.jsp"); 39 } 40 } 41 42 | Popular Tags |