| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 
 | package com.monpfe.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
 
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
 
import com.monpfe.metier.Agent;
import com.monpfe.persistance.AgentBean;
import com.monpfe.struts.form.AgentForm;
 
public class SubmitAction extends Action {
 
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response){
		AgentForm agentForm=(AgentForm) form;
		String forward=null;//,tache=null,login=null,passwd=null;
		//String tacheLog=null,tacheBean=null;
		HttpSession session=request.getSession();
		Agent agent=new Agent();
		AgentBean agentBean;
		//tache=agentForm.getTache();login=agentForm.getLogin();passwd=agentForm.getPasswd();
		agentBean=agent.login(agentForm.getTache(), agentForm.getLogin(), agentForm.getPasswd(),agentForm.getEmail());
		//agentForm.reset(mapping, request);
 
		if(agentBean !=null){
			//tacheBean=null;
			//tacheBean=agentBean.getTache();
			if((agentBean.getTache()).equalsIgnoreCase("admin")){
				session.setAttribute("logedUser", agentBean);
				forward=new String("successAdmin");
			}
			else if((agentBean.getTache()).equalsIgnoreCase("los")){
				session.setAttribute("logedUser", agentBean);
				forward=new String("successLos");
			}
			else if((agentBean.getTache()).equalsIgnoreCase("matrissage")){
				session.setAttribute("logedUser", agentBean);
				forward=new String("successMx");
			}
			else if((agentBean.getTache()).equalsIgnoreCase("architecture")){
				session.setAttribute("logedUser", agentBean);
				forward=new String("successArcht");
			}
			else if((agentBean.getTache()).equalsIgnoreCase("acquisition")){
				session.setAttribute("logedUser", agentBean);
				forward=new String("successAcqust");
			}
			return mapping.findForward(forward);
		}
		else {
			return mapping.findForward("failure");
		}
	}} | 
Partager