Struts

yahya6 Messages postés 6 Date d'inscription vendredi 24 février 2012 Statut Membre Dernière intervention 25 avril 2012 - 26 mars 2012 à 14:48
ganine Messages postés 1 Date d'inscription mardi 30 mai 2006 Statut Membre Dernière intervention 18 avril 2012 - 30 mars 2012 à 20:21
bonjour a tous . je suis en cour d developpement d un site web dynamique . j ai connu un probleme dans la vérification des donnés insere par l utilisateur " login et mot de passe " et les vérifier par celles dans la base de donné de ma table personnee. voila le code :

////////


package com.struts.controlleur;
import org.hibernate.*;
import com.ana.Personnee;
import com.util.HibernateUtil;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

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.struts.data.loginForm;
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;

public final class loginAction extends Action {



public ActionForward execute(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response) throws Exception {

String resultat = null;
String idUser = ((loginForm) form).getIdUser();
String passwordPersonne = ((loginForm) form).getPasswordPersonne();
if (idUser.equals("xyz") && passwordPersonne.equals("xyz")) {
resultat = "succes";
} else {
resultat = "echec";
}
return mapping.findForward(resultat);
}
}

/////
ici la vérification ce fait seulement sur les valeurs login = "xyz" w mt pass="xyz" mais j aime avoir comment verifier les donnés deja dans les collones de ma table.
voila aussi le code de personne.java car j utilise struts :::
///
package com.ana;

// Generated 18 mars 2012 14:55:00 by Hibernate Tools 3.2.0.beta8

/**
* Personnee generated by hbm2java
*/
public class Personnee implements java.io.Serializable {

// Fields

private String nomPersonne;
private String prenomPersonne;
private String villePersonne;
private String paysPersonne;
private String telephonePersonne;
private String emailPersonne;
private String idUser;
private String passwordPersonne;

// Constructors

/** default constructor */
public Personnee() {
}

/** minimal constructor */
public Personnee(String nomPersonne) {
this.nomPersonne = nomPersonne;
}

/** full constructor */
public Personnee(String nomPersonne, String prenomPersonne,
String villePersonne, String paysPersonne,
String telephonePersonne, String emailPersonne, String idUser,
String passwordPersonne) {
this.nomPersonne = nomPersonne;
this.prenomPersonne = prenomPersonne;
this.villePersonne = villePersonne;
this.paysPersonne = paysPersonne;
this.telephonePersonne = telephonePersonne;
this.emailPersonne = emailPersonne;
this.idUser = idUser;
this.passwordPersonne = passwordPersonne;
}

// Property accessors
public String getNomPersonne() {
return this.nomPersonne;
}

public void setNomPersonne(String nomPersonne) {
this.nomPersonne = nomPersonne;
}

public String getPrenomPersonne() {
return this.prenomPersonne;
}

public void setPrenomPersonne(String prenomPersonne) {
this.prenomPersonne = prenomPersonne;
}

public String getVillePersonne() {
return this.villePersonne;
}

public void setVillePersonne(String villePersonne) {
this.villePersonne = villePersonne;
}

public String getPaysPersonne() {
return this.paysPersonne;
}

public void setPaysPersonne(String paysPersonne) {
this.paysPersonne = paysPersonne;
}

public String getTelephonePersonne() {
return this.telephonePersonne;
}

public void setTelephonePersonne(String telephonePersonne) {
this.telephonePersonne = telephonePersonne;
}

public String getEmailPersonne() {
return this.emailPersonne;
}

public void setEmailPersonne(String emailPersonne) {
this.emailPersonne = emailPersonne;
}

public String getIdUser() {
return this.idUser;
}

public void setIdUser(String idUser) {
this.idUser = idUser;
}

public String getPasswordPersonne() {
return this.passwordPersonne;
}

public void setPasswordPersonne(String passwordPersonne) {
this.passwordPersonne = passwordPersonne;
}

}
///////////
/////
et voila le code de loginform
///////

package com.struts.data;



import org.apache.struts.action.*;

import javax.servlet.http.HttpServletRequest;



public class loginForm extends ActionForm {

/**
*
*/
private static final long serialVersionUID = 1L;
private String idUser;
private String passwordPersonne;

public String getIdUser() {
return this.idUser;
}

public void setIdUser(String idUser) {
this.idUser = idUser;
}

public String getPasswordPersonne() {
return this.passwordPersonne;
}

public void setPasswordPersonne(String passwordPersonne) {
this.passwordPersonne = passwordPersonne;
}


public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

return errors;

}

public void reset(ActionMapping mapping, HttpServletRequest request) {

this.idUser = null;

this.passwordPersonne = null;

}


}/////
et merci d avance :)
et merci

2 réponses

BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 103
26 mars 2012 à 14:55
Hello,
Du Java? Hop, je déplace dans la section Java


@+
Buno, Admin CS
L'urgent est fait, l'impossible est en cours. Pour les miracles, prévoir un délai...
0
ganine Messages postés 1 Date d'inscription mardi 30 mai 2006 Statut Membre Dernière intervention 18 avril 2012
30 mars 2012 à 20:21
dans ce site tu trouveras un TD pour te familiariser avec Struts
0
Rejoignez-nous