package com.cidat.proclets;

import javax.servlet.http.HttpSession;

public class SetValInSessionProclet implements Proclet {
	String valNameExpr;
	String valueExpr;
	boolean boCrearSesion = false;

	public SetValInSessionProclet(String valNameExpr, String valueExpr) {
		this(valNameExpr, valueExpr, false);
	}

	public SetValInSessionProclet(String valNameExpr, String valueExpr,
			boolean boCrearSesion) {
		this.valNameExpr = valNameExpr;
		this.valueExpr = valueExpr;
		this.boCrearSesion = boCrearSesion;
	}

	public void process(ProcletServiceData sd) throws ProcletException {
		HttpSession session = sd.req.getSession(this.boCrearSesion);
		if (session == null)
			throw new ProcletException(sd, "Imposible introducir "
					+ this.valNameExpr + ".No existe la sesion.");

		if (this.valueExpr == null) {
			session.removeValue(sd.evalExpr(this.valNameExpr));
			return;
		}
		session.putValue(sd.evalExpr(this.valNameExpr),
				sd.evalExpr(this.valueExpr));
	}
}

/*
 * Location:
 * D:\svn\ejie\q53.trunk\codigo\q53\q53ItourbaskWar\WebContent\WEB-INF\
 * lib\proclets_wl81.jar Qualified Name:
 * com.cidat.proclets.SetValInSessionProclet JD-Core Version: 0.6.0
 */