package foo; import java.sql.*; import java.io.IOException; import java.util.Hashtable; import java.util.Locale; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionServlet; import org.apache.struts.util.MessageResources; //import org.apache.struts.util.PropertyUtils; //import org.apache.struts.util.BeanUtils; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.PropertyUtils; public final class TestDBAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Extract attributes we will need Locale locale = getLocale(request); // MessageResources messages = getResources(); HttpSession session = request.getSession(); TestDBForm testDBForm = null; System.out.println("------------In TestDBAction---------------"); // Populate the user subject registration form if (form == null) { System.out.println("TestDBAction form was null"); /* if (servlet.getDebug() >= 1) servlet.log("Creating new TestDBForm bean under key " + mapping.getAttribute()); */ form = new TestDBForm(); System.out.println("TestDBForm is null. Creating new one"); if ("request".equals(mapping.getScope())) request.setAttribute(mapping.getAttribute(), form); else session.setAttribute(mapping.getAttribute(), form); } else { testDBForm = (TestDBForm) form; } TestData testData = new TestData(); System.out.println("loading"); testData.load(); System.out.println("copying Properties"); try { PropertyUtils.copyProperties(testDBForm, testData); } catch (Exception e) {System.out.println("e: " + e); e.printStackTrace();} // Set a transactional control token to prevent double posting /* if (servlet.getDebug() >= 1) getServlet.log("Setting transactional control token"); // servlet.log(" Setting transactional control token"); */ saveToken(request); // Forward control to the appropriate page /* if (servlet.getDebug() >= 1) servlet.log(" Forwarding to 'success' page"); */ return (mapping.findForward("success")); } }