<%!
//Se informa la variable m05bIdi 1.-Request; 2.-Session; 3.-Castellano
String m05bIdioma(HttpServletRequest request, HttpSession session){
	String m05bIdi = null;
	m05bIdi = request.getParameter("hz");
	if (m05bIdi==null){
		m05bIdi = (String)session.getAttribute("m05bIdi");
		if (m05bIdi==null){
			m05bIdi = "c";
			session.setAttribute("m05bIdi",m05bIdi);
		}
	}
	else{
		m05bIdi = m05bIdi.toLowerCase();
		session.setAttribute("m05bIdi",m05bIdi);
	}
	return m05bIdi;
}
%>
<%!
//Se informan las variables m05bPStmt; m05bConn.
int m05bNumConnects = 0;
String sql = null;
String sql_2 = null;
javax.sql.DataSource m05bDS = null;
java.sql.Connection m05bConn = null;
PreparedStatement m05bPStmt = null;
PreparedStatement m05bPStmt_2 = null;
ResultSet m05bRS = null;
ResultSet m05bRS_2 = null;
boolean m05bBeginSelect(String sql){
	javax.sql.DataSource ds = null;
	try{
		InitialContext ctx2 = new InitialContext();
		ds = (javax.sql.DataSource) ctx2.lookup("m05b.m05bDataSource");
	}
	catch (Exception NamingException) {
		NamingException.printStackTrace();
	}
	
	try{
		if (m05bNumConnects==0){
			m05bConn = ds.getConnection();
			m05bPStmt = m05bConn.prepareStatement(sql);
		}
		else{
			m05bPStmt_2 = m05bConn.prepareStatement(sql);
		}
		m05bNumConnects = m05bNumConnects + 1;
	}
	catch (Exception SQLException) {
		SQLException.printStackTrace();
	}
	return true;
}
boolean m05bEndSelect(){
	try{	
		if (m05bNumConnects==1){
			if(m05bRS!=null)
				m05bRS.close();
			if(m05bPStmt!=null)
				m05bPStmt.close();
		}
		else{
			if(m05bRS_2!=null)
				m05bRS_2.close();
			if(m05bPStmt_2!=null)
				m05bPStmt_2.close();
		}
		if (m05bNumConnects==1){
			if(m05bConn!=null)
				m05bConn.close();
		}
		m05bNumConnects = m05bNumConnects - 1;
	}
	catch (Exception SQLException) {
		SQLException.printStackTrace();
		return false;
	}
	return true;
}
%>
<%!
String m05bEntorno(HttpServletRequest request, HttpSession session){
	String entorno = null;
	entorno = (String)session.getAttribute("m05bEntorno");
	if (entorno == null){
		try{
			//Lectura del entorno de la base de datos de la aplicacin
			String ficheroProperties = "/aplic/m05b/html/datos/m05bEntorno.properties";
			FileInputStream inProperties = new FileInputStream(ficheroProperties);
			//Apertura
			Properties aProperties = new Properties();
			aProperties.load(inProperties);
			
			//Carga
			entorno = aProperties.getProperty("entorno");
			if (entorno == null || entorno.length() == 0 || !entorno.equals("intranet"))
				entorno = "internet";
			inProperties.close();
		} catch(Exception e) {
		m05bClasses.m05bFileLog miLog = new m05bClasses.m05bFileLog();
			miLog.addTraza(e);
		}
		finally{
			session.setAttribute("m05bEntorno",entorno);
		}
	}
	return entorno;
}
%>

