// File LoginServlet.java
package com.vantra.volts.core.action;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

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;


/**
 * Implementation of <strong>Action</strong> that validates a user logon.
 *
 * @author Misak M. Boulatian
 * @version $Revision: 1.0 $ $Date: 2000/12/05 14:16:00 $
 */

public class LoginAction extends Action {

    // --------------------------------------------------------- Public Methods


    /**
     * Process the specified HTTP request, and create the corresponding HTTP
     * response (or forward to another web component that will create it).
     * Return an <code>ActionForward</code> instance describing where and how
     * control should be forwarded, or <code>null</code> if the response has
     * already been completed.
     *
     * @param mapping The ActionMapping used to select this instance
     * @param actionForm The optional ActionForm bean for this request (if any)
     * @param request The HTTP request we are processing
     * @param response The HTTP response we are creating
     *
     * @exception IOException if an input/output error occurs
     * @exception ServletException if a servlet exception occurs
     */
    public ActionForward perform(ActionMapping mapping,
				 ActionForm form,
				 HttpServletRequest request,
				 HttpServletResponse response)
	throws IOException, ServletException {

ActionForward forward = mapping.findForward("success");
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		if (form == null)
		out.println("<html><head><title>test data</title></head>" +
					"<body><br>user name =  " +
					"<br>password = " +
					"<br>mapped path = " + forward.getPath() +
					"</body></html>");
		else
		out.println("<html><head><title>test data</title></head>" +
					"<body><br>user name =  " + ((LoginForm) form).getUsername() +
					"<br>password = " + ((LoginForm) form).getPassword() +
					"<br>mapped path = " + forward.getPath() +
					"</body></html>");
		return (ActionForward) null;

//return (mapping.findForward("success"));
}
}

