package register;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.*;
public class MyRequestProcessor extends RequestProcessor
{
    public MyRequestProcessor()
{
        try {
            jbInit();
                  } catch (Exception ex) { ex.printStackTrace();}
    }
    public boolean processPreprocess(HttpServletRequest request, HttpServletResponse response)
        {
        String path = request.getRequestURI();
          System.out.println(path);
          if (path.indexOf("register.do") != -1)
{
                try {
                        HttpSession session = request.getSession();
                        RegisterActionForm registerActionForm = (
                                RegisterActionForm) session.getAttribute(
                                        "registerActionForm");
                         if(registerActionForm!=null)
{
                             boolean accepted = registerActionForm.isAccepted();
                                       if(accepted)
{ return true; }
                                       else
{
                                                        this.doForward("/error.jsp",request, response);
                                                        return false;
                                        }
                          }
                          this.doForward("/error.jsp",request, response);
                          return false;
                  }
                  catch (IOException e) { System.out.println(e); }
                  catch (ServletException se) { System.out.println(se); }
        }
        return true;
    }
    private void jbInit() throws Exception
{ }
}
