mercredi 3 juin 2015

cheking email if already exists

i'm using this method to defin if email already exists in the database for my registration page

public boolean  checkmail(String  emailMembre ){
        Session s=factory.openSession();
        Transaction tx=s.beginTransaction();
        Query query= s.createSQLQuery("select COUNT(*) from tmembre where email='"+emailMembre +"'");
        query.setParameter(1, emailMembre);
        int rs = 0;
         rs = ((Number) query.uniqueResult()).intValue();
         if (rs > 0){
             return false;
         }

        return true;
    }

and

public  String ajouter() {      

        boolean resu = service.checkmail(emailMembre);
        if (resu){
            Membre m=new Membre(idMembre, emailMembre , nomMembre,telMembre,mdpMembre,typeMembre);

            boolean  resultat=service.ajouter(m);
        if (resultat)
            return SUCCESS;
        else 
            return ERROR;
        }else 
            return ERROR;

    }

web.xml

<filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <welcome-file-list>

        <welcome-file>/inscription.html</welcome-file>
    </welcome-file-list>

the exception is javax.servlet.servletexception filter execution threw an exception

Aucun commentaire:

Enregistrer un commentaire