Tokenizer ou autre methode

MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004 - 18 sept. 2003 à 15:04
TchilKiller Messages postés 1 Date d'inscription dimanche 22 décembre 2002 Statut Membre Dernière intervention 27 décembre 2004 - 27 déc. 2004 à 12:38
Mars'L :-p
salut je recupere dans la variable(tableau) str_appli_lieu_install[] de ma templates une suite d'index que je veux insérer dans un meme champ de ma DB SQL.
ex: str_appli_lieu_install[] = 152 86 189
152, 86 et 189 sont 3 index distinct.
le nombre d'index contenus ds cette variable n'est pas fixe. il peut aller de 2 a 30 parexemple voir plus.

je souhaite faire une boucle qui tant qu'il y a des valeurs ds les cases de str_appli_lieu_install me donne une autre variable avec les index séparé par une virgule par exemple:
str_groupe_postes = 152, 86, 189

Puis refaire dansune autre template, l'inverse soit prendre str_groupe_postes et ressortir les index un par un donc ds un tableau pour ensuite les visualiser.

voici mon source :

/*
* LGAppli_application_insertion.java
*
* Created on 7 juillet 2003, 15:13
*/

import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import org.apache.log4j.*;
import java.util.*;
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.*;

/**
*
* @author Mars'L
* @version
*/
public class LGAppli_application_insertion extends HttpServlet {

/** Initializes the servlet.
*/
static String URL_CONNECTION_LGAPPLI;
static String URL_USER_LGAPPLI;
static String URL_PASSWORD_LGAPPLI;
Connection LGAppli_con;
static Logger logger = Logger.getLogger(LGAppli_application_insertion.class.getName());

static String URL_CONNECTION_LGRESA;
static String URL_USER_LGRESA;
static String URL_PASSWORD_LGRESA;
Connection LGResa_con;
static String URL_CONNECTION_LGINC;
static String URL_USER_LGINC;
static String URL_PASSWORD_LGINC;
Connection LGInc_con;
static String DBDRIVER;
static String CHEMIN_TEMPLATE;
static String PREFIX;


public void init(ServletConfig config) throws ServletException {
super.init(config);
PREFIX = getServletContext().getRealPath("/");
String file = getInitParameter("chemin_log");

URL_USER_LGAPPLI = getInitParameter("dbuser_lgappli");
URL_PASSWORD_LGAPPLI = getInitParameter("dbmdp_lgappli");
URL_USER_LGRESA = getInitParameter("dbuser_lgresa");
URL_PASSWORD_LGRESA = getInitParameter("dbmdp_lgresa");
URL_CONNECTION_LGAPPLI = getInitParameter("dburl_lgappli");
URL_CONNECTION_LGRESA = getInitParameter("dburl_lgresa");
URL_USER_LGINC = getInitParameter("dbuser_lginc");
URL_PASSWORD_LGINC = getInitParameter("dbmdp_lginc");
URL_CONNECTION_LGINC = getInitParameter("dburl_lginc");
DBDRIVER = getInitParameter("dbdriver");

if ( file != null )
PropertyConfigurator.configure(PREFIX+file);

CHEMIN_TEMPLATE = getInitParameter("chemin_template");

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() );
}

}

/** Destroys the servlet.
*/
public void destroy() {

}

/** Processes requests for both HTTP
GET
and
POST
methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
Template outty = null;
ServletOutputStream out = response.getOutputStream();
Writer writer = new OutputStreamWriter(out);

LinkedHashMap ligne = new LinkedHashMap();
ArrayList vm_appli_type_install = new ArrayList();
ArrayList vm_appli_mat_install = new ArrayList();
ArrayList vm_editeur = new ArrayList();
PreparedStatement lgappli_stmt;
PreparedStatement lgresa_stmt;
PreparedStatement lginc_stmt;
ResultSet lgappli_rs;
ResultSet lgresa_rs;
ResultSet lginc_rs;
String str_appli = request.getParameter("appli"); if ( str_appli null ) str_appli "";
if ( str_appli.equals("null") ) str_appli = "";
String str_appli_nom = request.getParameter("appli_nom"); if ( str_appli_nom null ) str_appli_nom "";
if ( str_appli_nom.equals("null") ) str_appli_nom = "";
String str_appli_version = request.getParameter("appli_version"); if ( str_appli_version null ) str_appli_version "";
if ( str_appli_version.equals("null") ) str_appli_version = "";
String str_appli_description = request.getParameter("appli_description"); if ( str_appli_description null ) str_appli_description "";
if ( str_appli_description.equals("null") ) str_appli_description = "";
String str_appli_date_recep = request.getParameter("appli_date_recep"); if ( str_appli_date_recep null ) str_appli_date_recep "";
if ( str_appli_date_recep.equals("null") ) str_appli_date_recep = "";
String str_appli_nb_licence = request.getParameter("appli_nb_licence"); if ( str_appli_nb_licence null ) str_appli_nb_licence "";
if ( str_appli_nb_licence.equals("null") ) str_appli_nb_licence = "";
String str_appli_ddv = request.getParameter("appli_ddv"); if ( str_appli_ddv null ) str_appli_ddv "";
if ( str_appli_ddv.equals("null") ) str_appli_ddv = "";
String str_appli_dfv = request.getParameter("appli_dfv"); if ( str_appli_dfv null ) str_appli_dfv "";
if ( str_appli_dfv.equals("null") ) str_appli_dfv = "";
String str_appli_maint = request.getParameter("appli_maint"); if ( str_appli_maint null ) str_appli_maint "";
if ( str_appli_maint.equals("null") ) str_appli_maint = "";
String str_appli_proc_install = request.getParameter("appli_proc_install"); if ( str_appli_proc_install null ) str_appli_proc_install "";
if ( str_appli_proc_install.equals("null") ) str_appli_proc_install = "";
String str_appli_lieu_stock = request.getParameter("appli_lieu_stock"); if ( str_appli_lieu_stock null ) str_appli_lieu_stock "";
if ( str_appli_lieu_stock.equals("null") ) str_appli_lieu_stock = "";
String str_appli_mat_recep = request.getParameter("appli_mat_recep"); if ( str_appli_mat_recep null ) str_appli_mat_recep "";
if ( str_appli_mat_recep.equals("null") ) str_appli_mat_recep = "";
String str_editeur = request.getParameter("editeur"); if ( str_editeur null ) str_editeur "";
if ( str_editeur.equals("null") ) str_editeur = "";
String str_appli_date_install = request.getParameter("appli_date_install"); if ( str_appli_date_install null ) str_appli_date_install "";
if ( str_appli_date_install.equals("null") ) str_appli_date_install = "";
String str_appli_lieu_diff = request.getParameter("appli_lieu_diff"); if ( str_appli_lieu_diff null ) str_appli_lieu_diff "";
if ( str_appli_lieu_diff.equals("null") ) str_appli_lieu_diff = "";
String str_appli_type_install = request.getParameter("appli_type_install"); if ( str_appli_type_install null ) str_appli_type_install "";
if ( str_appli_type_install.equals("null") ) str_appli_type_install = "";
String str_appli_mat_install = request.getParameter("appli_mat_install"); if ( str_appli_mat_install null ) str_appli_mat_install "";
if ( str_appli_mat_install.equals("null") ) str_appli_mat_install = "";
String[] str_appli_lieu_install = request.getParameterValues("appli_lieu_install");
String str_groupe_postes;


String str_appli_nom_interloc = request.getParameter("appli_nom_interloc"); if ( str_appli_nom_interloc null ) str_appli_nom_interloc "";
if ( str_appli_nom_interloc.equals("null") ) str_appli_nom_interloc = "";
String str_appli_prenom_interloc = request.getParameter("appli_prenom_interloc"); if ( str_appli_prenom_interloc null ) str_appli_prenom_interloc "";
if ( str_appli_prenom_interloc.equals("null") ) str_appli_prenom_interloc = "";
String str_appli_tel_interloc = request.getParameter("appli_tel_interloc"); if ( str_appli_tel_interloc null ) str_appli_tel_interloc "";
if ( str_appli_tel_interloc.equals("null") ) str_appli_tel_interloc = "";
String str_appli_mail_interloc = request.getParameter("appli_mail_interloc"); if ( str_appli_mail_interloc null ) str_appli_mail_interloc "";
if ( str_appli_mail_interloc.equals("null") ) str_appli_mail_interloc = "";
String str_appli_fax_interloc = request.getParameter("appli_fax_interloc"); if ( str_appli_fax_interloc null ) str_appli_fax_interloc "";
if ( str_appli_fax_interloc.equals("null") ) str_appli_fax_interloc = "";
String str_appli_os = request.getParameter("appli_os"); if ( str_appli_os null ) str_appli_os "";
if ( str_appli_os.equals("null") ) str_appli_os = "";
String vm_appli = str_appli;
String vm_appli_nom = "";
String vm_appli_version = "";
String vm_appli_description = "";
String vm_appli_date_recep = "";
String vm_appli_nb_licence = "";
String vm_appli_ddv = "";
String vm_appli_dfv = "";
String vm_appli_maint = "";
String vm_appli_proc_install = "";
String vm_appli_lieu_stock = "";
String vm_appli_mat_recep = "";
String vm_appli_editeur_index = "";
String vm_appli_install_index = "";
String vm_appli_date_install = "";
String vm_appli_type_install_index = "";
String vm_appli_lieu_diff = "";
String vm_appli_matricule_install = "";
String vm_appli_sp_index = "";
String vm_appli_interloc_nom = "";
String vm_appli_interloc_prenom = "";
String vm_appli_interloc_tel = "";
String vm_appli_interloc_mail = "";
String vm_appli_interloc_fax = "";
String vm_resultat = "";
String vm_appli_type_install_sel_valeur = "";
String vm_appli_type_install_sel_nom = "";
String vm_appli_mat_install_nom = "";
String vm_appli_mat_install_index = "";
ArrayList vm_appli_lieu_install = new ArrayList();
ArrayList vm_appli_os = new ArrayList();

String bouton_creer = request.getParameter("bouton_creer"); if ( bouton_creer null ) bouton_creer "";
if ( bouton_creer.equals("null") ) bouton_creer = "";

//Acces au driver de la DB
try {
Class.forName(DBDRIVER);
}
catch (ClassNotFoundException ex) {
logger.fatal("Driver non trouve");
logger.fatal(ex.toString());
}

// Ouverture de la connection avec la DB LGAppli
try {
LGAppli_con = DriverManager.getConnection(URL_CONNECTION_LGAPPLI,URL_USER_LGAPPLI, URL_PASSWORD_LGAPPLI);

}
catch (SQLException ex) {
logger.fatal("SQLException acces LGAppli : " + ex.getMessage());
}
// Ouverture de la connection avec la DB LGResa
try {
LGResa_con = DriverManager.getConnection(URL_CONNECTION_LGRESA,URL_USER_LGRESA, URL_PASSWORD_LGRESA);

}
catch (SQLException ex) {
logger.fatal("SQLException acces LGResa : " + ex.getMessage());
}
// Ouverture de la connection avec la DB LGInc
try {
LGInc_con = DriverManager.getConnection(URL_CONNECTION_LGINC,URL_USER_LGINC, URL_PASSWORD_LGINC);

}
catch (SQLException ex) {
logger.fatal("SQLException acces LGInc : " + ex.getMessage());
}


if ( bouton_creer.equals("Creer") ) {

// Insert ds la DB LGAppli table_application
try {
lgappli_stmt = LGAppli_con.prepareStatement("INSERT INTO table_application (COL_APPLI_NOM, COL_APPLI_DESCRIP, COL_APPLI_VERSION, COL_APPLI_DATE_RECEPTION, COL_APPLI_NB_LICENCE, COL_APPLI_DDV, COL_APPLI_DFV, COL_APPLI_STOCKAGE, COL_APPLI_MATRICULE, COL_APPLI_EDITEUR_INDEX, COL_APPLI_OS, COL_APPLI_CONTRATMAINTENANCE, COL_APPLI_INSTALLATION_INDEX, COL_APPLI_PROCEDURE_INSTALL) values ('" + str_appli_nom + "', '" + str_appli_description + "', '" + str_appli_version + "', '" + str_appli_date_recep + "', '" + str_appli_nb_licence + "', '" + str_appli_ddv + "', '" + str_appli_dfv + "', '" + str_appli_lieu_stock + "', '" + str_appli_mat_recep + "', '" + str_editeur + "', '" + str_appli_os + "', '" + str_appli_maint + "', '" + 0 + "', '" + str_appli_proc_install + "')");
lgappli_rs = lgappli_stmt.executeQuery();
}
catch ( SQLException ex) {
logger.warn("Exception 12 : SQL " + ex.getMessage().toString());
}
// Requete ds la DB LGAppli table_application on recupere l'index cree lors de l'insert
try { lgappli_stmt LGAppli_con.prepareStatement("SELECT COL_APPLI_INDEX FROM table_application WHERE COL_APPLI_NOM '" + str_appli_nom + "'");
lgappli_rs = lgappli_stmt.executeQuery();
while ( lgappli_rs.next() ) {
str_appli = lgappli_rs.getString("COL_APPLI_INDEX");
}
}
catch ( SQLException ex) {
logger.warn("Exception 13 : SQL " + ex.getMessage().toString());
}
//Insert ds la DB LGAppli table_interlocuteur
try {
lgappli_stmt = LGAppli_con.prepareStatement("INSERT INTO table_interlocuteur (COL_INTERLOC_NOM, COL_INTERLOC_PRENOM, COL_INTERLOC_TELEPHONE, COL_INTERLOC_MAIL, COL_INTERLOC_FAX, COL_INTERLOC_APPLICATION) values('" + str_appli_nom_interloc + "', '" + str_appli_prenom_interloc + "', '" + str_appli_tel_interloc + "', '" + str_appli_mail_interloc + "', '" + str_appli_fax_interloc + "', '" + str_appli + "')");
lgappli_rs = lgappli_stmt.executeQuery();
}
catch ( SQLException ex) {
logger.warn("Exception 14 : SQL " + ex.getMessage().toString());
}
// Insert ds la DB LGAppli table_installation
logger.info("Lieu installation : index des postes :" + str_appli_lieu_install[0] + " " + str_appli_lieu_install[1] + " " + str_appli_lieu_install[2]);
try {
lgappli_stmt = LGAppli_con.prepareStatement("INSERT INTO table_installation (COL_INSTALLATION_DATE, COL_INSTALLATION_LIEUDIFFUSION, COL_INSTALLATION_TYPE, COL_INSTALLATION_MATRICULE, COL_INSTALLATION_POSTE, COL_INSTALLATION_APPLI_INDEX) values('" + str_appli_date_install + "', '" + str_appli_lieu_diff + "', '" + str_appli_type_install + "', '" + str_appli_mat_install + "', '" + str_appli_lieu_install + "', '" + str_appli + "')");
lgappli_rs = lgappli_stmt.executeQuery();
}
catch ( SQLException ex) {
logger.warn("Exception 15 : SQL " + ex.getMessage().toString());
}
vm_resultat = "Création effectuée";
logger.info("Creation de l'application " + str_appli_nom);
}
//Recuperation de l'application à modifier
// Requete ds la DB LGAppli table_application suivant l'index
try { lgappli_stmt LGAppli_con.prepareStatement("SELECT * FROM table_application WHERE COL_APPLI_INDEX '" + str_appli + "'");
lgappli_rs = lgappli_stmt.executeQuery();
// on recupere les donnees
while ( lgappli_rs.next() ) {
vm_appli_nom = lgappli_rs.getString("COL_APPLI_NOM");
vm_appli_version = lgappli_rs.getString("COL_APPLI_VERSION");
vm_appli_description = lgappli_rs.getString("COL_APPLI_DESCRIP");
vm_appli_date_recep = lgappli_rs.getString("COL_APPLI_DATE_RECEPTION");
vm_appli_nb_licence = lgappli_rs.getString("COL_APPLI_NB_LICENCE");
vm_appli_ddv = lgappli_rs.getString("COL_APPLI_DDV");
vm_appli_dfv = lgappli_rs.getString("COL_APPLI_DFV");
vm_appli_maint = lgappli_rs.getString("COL_APPLI_CONTRATMAINTENANCE");
vm_appli_proc_install = lgappli_rs.getString("COL_APPLI_PROCEDURE_INSTALL");
vm_appli_lieu_stock = lgappli_rs.getString("COL_APPLI_STOCKAGE");
vm_appli_mat_recep = lgappli_rs.getString("COL_APPLI_MATRICULE");
vm_appli_editeur_index = lgappli_rs.getString("COL_APPLI_EDITEUR_INDEX");
vm_appli_install_index = lgappli_rs.getString("COL_APPLI_INSTALLATION_INDEX");
}
} catch (SQLException ex) {
logger.warn("Exception 3 : SQL " + ex.getMessage().toString());
}

// Requete ds la DB LGAppli table_installation suivant l'index
try { lgappli_stmt LGAppli_con.prepareStatement("SELECT * FROM table_installation WHERE COL_INSTALLATION_APPLI_INDEX '" + str_appli + "'");
lgappli_rs = lgappli_stmt.executeQuery();
while ( lgappli_rs.next() ) {
vm_appli_date_install = lgappli_rs.getString("COL_INSTALLATION_DATE");
vm_appli_type_install_index = lgappli_rs.getString("COL_INSTALLATION_TYPE");
vm_appli_lieu_diff = lgappli_rs.getString("COL_INSTALLATION_LIEUDIFFUSION");
vm_appli_matricule_install = lgappli_rs.getString("COL_INSTALLATION_MATRICULE");
vm_appli_sp_index = lgappli_rs.getString("COL_INSTALLATION_POSTE");
}
} catch (SQLException ex) {
logger.warn("Exception 4 : SQL " + ex.getMessage().toString());
}

//Recuperation du type d'installation
try {
lgappli_stmt = LGAppli_con.prepareStatement("SELECT * FROM table_typeinstall");
lgappli_rs = lgappli_stmt.executeQuery();
while ( lgappli_rs.next() ) {
ligne = new LinkedHashMap();
ligne.put("index", lgappli_rs.getString("COL_TYPEINSTALL_INDEX"));
ligne.put("nom", lgappli_rs.getString("COL_TYPEINSTALL_TYPE"));
vm_appli_type_install.add(ligne);

}
} catch (SQLException ex) {
logger.warn("Exception 5 : SQL " + ex.getMessage().toString());
}

// Requete ds la DB LGResa table_mdp
try {
lgresa_stmt = LGResa_con.prepareStatement("SELECT * FROM table_mdp ORDER BY MDP_USER ASC");
lgresa_rs = lgresa_stmt.executeQuery();
while ( lgresa_rs.next() ) {
ligne = new LinkedHashMap();
ligne.put("index", lgresa_rs.getString("MDP_INDEX"));
ligne.put("nom", lgresa_rs.getString("MDP_USER"));
vm_appli_mat_install.add(ligne);
}
} catch (SQLException ex) {
logger.warn("Exception 7 : SQL " + ex.getMessage().toString());
}

// Requete ds la DB LGAppli table_editeur
try {
lgappli_stmt = LGAppli_con.prepareStatement("SELECT * FROM table_editeur ORDER BY COL_EDITEUR_NOM ASC");
lgappli_rs = lgappli_stmt.executeQuery();
while (lgappli_rs.next()) {
ligne = new LinkedHashMap();
ligne.put("index", lgappli_rs.getObject("COL_EDITEUR_INDEX"));
ligne.put("nom", lgappli_rs.getString("COL_EDITEUR_NOM"));
vm_editeur.add(ligne);
}
} catch ( SQLException ex ) {
logger.warn("Exception 8 : SQL " + ex.getMessage().toString());
}

// Requete ds la DB LGResa table_reservation
try {
lgresa_stmt = LGResa_con.prepareStatement("SELECT * FROM table_reservation ORDER BY SP_NOM ASC");
lgresa_rs = lgresa_stmt.executeQuery();
while (lgresa_rs.next()) {
ligne = new LinkedHashMap();
ligne.put("index", lgresa_rs.getObject("SP_INDEX"));
ligne.put("nom", lgresa_rs.getString("SP_NOM"));
vm_appli_lieu_install.add(ligne);
}
} catch ( SQLException ex ) {
logger.warn("Exception 9 : SQL " + ex.getMessage().toString());
}

// Requete ds la DB LGInc table_type

try { lginc_stmt LGInc_con.prepareStatement("SELECT * FROM table_sous_type WHERE COL_TYPE_TYPE 3");
lginc_rs = lginc_stmt.executeQuery();
while ( lginc_rs.next() ) {
ligne = new LinkedHashMap();
ligne.put("index", lginc_rs.getObject("COL_INDEX_SS_TYPE").toString());
ligne.put("nom", lginc_rs.getString("COL_LIBELLE_SS_TYPE"));
vm_appli_os.add(ligne);
}
} catch (SQLException ex) {
logger.warn("Exception 5 : SQL " + ex.getMessage().toString());
}

try {
outty = Velocity.getTemplate("LGAppli_application_insertion.vm");
VelocityContext Vctx = new VelocityContext();
Vctx.put("vm_appli", vm_appli);
Vctx.put("vm_appli_nom", vm_appli_nom);
Vctx.put("vm_appli_version", vm_appli_version);
Vctx.put("vm_appli_description", vm_appli_description);
Vctx.put("vm_appli_date_recep", vm_appli_date_recep);
Vctx.put("vm_appli_nb_licence", vm_appli_nb_licence);
Vctx.put("vm_appli_ddv", vm_appli_ddv);
Vctx.put("vm_appli_dfv", vm_appli_dfv);
Vctx.put("vm_appli_maint", vm_appli_maint);
Vctx.put("vm_appli_proc_install", vm_appli_proc_install);
Vctx.put("vm_appli_lieu_stock", vm_appli_lieu_stock);
Vctx.put("vm_appli_mat_recep", vm_appli_mat_recep);
Vctx.put("vm_appli_editeur_index", vm_appli_editeur_index);
Vctx.put("vm_appli_install_index", vm_appli_install_index);
Vctx.put("vm_appli_type_install", vm_appli_type_install);
Vctx.put("vm_appli_mat_install", vm_appli_mat_install);
Vctx.put("vm_appli_date_install", vm_appli_date_install);
Vctx.put("vm_appli_type_install_index", vm_appli_type_install_index);
Vctx.put("vm_appli_matricule_install", vm_appli_matricule_install);
Vctx.put("vm_appli_lieu_diff", vm_appli_lieu_diff);
Vctx.put("vm_appli_sp_index", vm_appli_sp_index);
Vctx.put("vm_editeur", vm_editeur);
Vctx.put("vm_appli_interloc_nom", vm_appli_interloc_nom);
Vctx.put("vm_appli_interloc_prenom", vm_appli_interloc_prenom);
Vctx.put("vm_appli_interloc_tel", vm_appli_interloc_tel);
Vctx.put("vm_appli_interloc_mail", vm_appli_interloc_mail);
Vctx.put("vm_appli_interloc_fax", vm_appli_interloc_fax);
Vctx.put("vm_resultat", vm_resultat);
Vctx.put("vm_appli_type_install_sel_valeur", vm_appli_type_install_sel_valeur);
Vctx.put("vm_appli_type_install_sel_nom", vm_appli_type_install_sel_nom);
Vctx.put("vm_appli_mat_install_nom", vm_appli_mat_install_nom);
Vctx.put("vm_appli_mat_install_index", vm_appli_mat_install_index);
Vctx.put("vm_appli_lieu_install", vm_appli_lieu_install);
Vctx.put("vm_appli_os", vm_appli_os);
outty.merge(Vctx, writer);
writer.flush();
} catch( ParseErrorException pee ) {
logger.fatal("parse error for template " + pee.toString());
} catch( ResourceNotFoundException rnfe ) {
logger.fatal("template not found " + rnfe.toString());
} catch( Exception e ) {
logger.fatal("Error velocity " + e.toString());
}

/* c ici que je ne c comment faire*/

>> try {
while( str_appli_lieu_install < str_appli_install[].

}

}

/** Handles the HTTP
GET
method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}

/** Handles the HTTP
POST
method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
}

Merci d'avance

8 réponses

cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 11
18 sept. 2003 à 15:50
salut,
si tu utilises le sdk 1.4.x tu as la fonction split dans la classe String qui te permet d'éclater une chaine selon un separateur et qui te renvoit un tableau
pour un sdk anterieur c est avec le tokenizer
Duss
0
MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004
18 sept. 2003 à 16:27
Mars'L :-p

merci pour l'info mais je ne sais pas comment l'utiliser.
0
cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 11
18 sept. 2003 à 16:38
lequel ?
0
MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004
18 sept. 2003 à 19:27
Mars'L :-p

j'utilise jsd1.4.1 donc j'ai bien la methode split ds String mais je ne sais pas l'utilisee.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 11
18 sept. 2003 à 23:57
String[] tablo = "aa,bb,cc,dd".split(",");
Duss
0
MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004
19 sept. 2003 à 11:17
Mars'L :-p

dans mon source j'ai testé split :

str_appli_lieu_install = "aa,bb,cc,dd".split(",");
//recupere valeur ds log
logger.info("résultat split : str_appli_lieu_install = " + str_appli_lieu_install );

fichier log :
valeur de str_appli_lieu_install avant split:
Lieu installation : index des postes :188 190 193

valeur de str_appli_lieu_install apres split:
str_appli_lieu_install = [Ljava.lang.String;@106daba

s que tu peux m'aider plus en detail parce que je galere grave. sinon peut etre que tokenizer serai plus simple je c pas pour moi l'un comme l'autre j'ai trop de mal.
merci
0
cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 11
19 sept. 2003 à 13:47
split te renvoit un tableau !!!!
tu ne peux pas l afficher comme ca ;)
il faut que lu parcours sinon il t ecris son adresse memoire (ce qu il t as fais)
String [] str_appli_lieu_install = "aa,bb,cc,dd".split(",");
//recupere valeur ds log
for (int i=0 ; i < str_appli_lieu_install.length ; i++)
logger.info("résultat split : str_appli_lieu_install["+i+"] = " + str_appli_lieu_install[i] );

Duss
0
TchilKiller Messages postés 1 Date d'inscription dimanche 22 décembre 2002 Statut Membre Dernière intervention 27 décembre 2004
27 déc. 2004 à 12:38
tu devrais utiliser le streamtokenizer(file) ou stringTokenizer(chaine characteres). Tu specifie un charactere qui defini la separation de champs et lui balaie ta string en prenant chaque fois que la partie qui est entre ton separateur.puis tu passe au suivant etc... Actuellement, ta solution peut fonctionner mais risque qd meme detre lourde, il me semble.
Sans code source ca va te souler donc jtenvoie du code ;-)
strToken = new StringTokenizer(mastring, ",", true);
string tmp=strToken.nextToken(",");

Allez token powaaa & good luck



BeTchil
0
Rejoignez-nous