/* * LGresa_Creation_Detail.java * */ import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import org.apache.log4j.*; import org.apache.velocity.*; import org.apache.velocity.runtime.*; import org.apache.velocity.app.*; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.exception.ParseErrorException; import java.io.*; import java.util.*; import java.lang.*; /** * * @author r001485 * Creation d'une template Velocity * Creation d'une servlet pour creer les fiches d'identité des postes * @version */ public class LGResa_Creation_Detail extends HttpServlet { static String URL_CONNECTION_LGRESA; static String URL_USER_LGRESA; static String URL_PASSWORD_LGRESA; Connection con_lgresa; static Logger logger = Logger.getLogger(LGResa_Creation_Detail.class.getName()); static String URL_CONNECTION_LGINC; static String URL_USER_LGINC; static String URL_PASSWORD_LGINC; Connection con_lginc; static String CHEMIN_TEMPLATE; static String URL_DRIVER; static String createur; /** Initializes the servlet. */ public void init(ServletConfig config) throws ServletException { super.init(config); String prefix = getServletContext().getRealPath("/"); String file = getInitParameter("chemin_log"); URL_USER_LGRESA = getInitParameter("dbuser_lgresa"); URL_PASSWORD_LGRESA = getInitParameter("dbmdp_lgresa"); URL_CONNECTION_LGRESA = getInitParameter("dburl_lgresa"); URL_USER_LGINC = getInitParameter("dbuser_lginc"); URL_PASSWORD_LGINC = getInitParameter("dbmdp_lginc"); URL_CONNECTION_LGINC = getInitParameter("dburl_lginc"); URL_DRIVER = getInitParameter("dbdriver"); CHEMIN_TEMPLATE = getInitParameter("chemin_template"); if ( file != null) PropertyConfigurator.configure(prefix+file); if ( CHEMIN_TEMPLATE != null ) CHEMIN_TEMPLATE = prefix + CHEMIN_TEMPLATE; try { //Initialisation de Velocity Properties props = new Properties(); props.load(new FileInputStream(CHEMIN_TEMPLATE)); Velocity.init( props ); } catch (Exception e ) { logger.warn("erreur velocity " + e.toString() ); } } public void Test_Saisie(String saisie1, String vm_saisie1, String vm_saisie_champs){ // logger.info("appel de la methode"+ saisie1 +","+ vm_saisie1 +", "+ vm_erreur_saisie1 +", "+ vm_affiche_erreur); if ( ! vm_saisie1.equals("")){ if ((saisie1.indexOf(" ") != -1) || (saisie1.indexOf(",") != -1) || (saisie1.indexOf(".") != -1)){ vm_saisie1 = saisie1.replaceAll(" ","").replaceAll(",","."); vm_saisie_champs = ""; } try{ Float.parseFloat(vm_saisie1); }catch (NumberFormatException ex) { logger.warn("Erreur " + ex.getMessage().toString()); if ( ! ex.equals("")) vm_saisie_champs = "swap"; logger.info(ex +" - vm_saisie_champs :" + vm_saisie_champs); } } } // Test_Saisie(swap, vm_swap, vm_saisie_swap); /* if ( ! vm_swap.equals("")){ //indexOf("x") renvoi -1 si x pas present dans la chaine ou 3 si present // On supprime les espaces if ((swap.indexOf(" ") != -1) || (swap.indexOf(",") != -1) || (swap.indexOf(".") != -1)){ vm_swap = swap.replaceAll(" ","").replaceAll(",","."); } try{ Float.parseFloat(vm_swap); }catch (NumberFormatException ex) { logger.warn("swap " + ex.getMessage().toString()); if ( ! ex.equals("")) vm_saisie_swap = "swap"; } } */ /** Destroys the servlet. */ public void destroy() { } /** Processes requests for both HTTP <code>GETand
POSTmethods.
GETmethod.
POSTmethod.
if ( ! vm_swap.equals("")){ //indexOf("x") renvoi -1 si x pas present dans la chaine ou 3 si present // On supprime les espaces if ((swap.indexOf(" ") != -1) || (swap.indexOf(",") != -1) || (swap.indexOf(".") != -1)){ vm_swap = swap.replaceAll(" ","").replaceAll(",","."); }
public void test_Saisie(String saisie1, String vm_saisie1, String vm_saisie_champs){ logger.info("appel de la methode"+ saisie1 +","+ vm_saisie1 +", "+ vm_saisie_champs); if ( ! vm_saisie1.equals("")){ if ((saisie1.indexOf(" ") != -1) || (saisie1.indexOf(",") != -1) || (saisie1.indexOf(".") != -1)){ vm_saisie1 = saisie1.replaceAll(" ","").replaceAll(",","."); vm_saisie_champs = ""; } try{ Float.parseFloat(vm_saisie1); }catch (NumberFormatException ex) { logger.warn("Erreur " + ex.getMessage().toString()); if ( ! ex.equals("")) vm_saisie_champs = "swap"; logger.info(ex +" - vm_saisie_champs :" + vm_saisie_champs); } } }