Switch to full style
JSP Code Examples
Post a reply

validate mail in jsp

Tue Jan 20, 2009 11:44 pm

validate mail in jsp (Java server pages ) , the following code contain two snippet ,the first one is using custom tags ,the second is a java bean class.

1. JSP FIle
Code:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>


<jsp:useBean id="mailcheck" class="codemiles.mailchecker" >
<jsp:setProperty name="mailcheck" property="*" />
</jsp:useBean>
<%-- get valid property from ClientValidator bean --%>
<c:set var="isValid" value="${mailcheck.valid}" />
<c:if test="${isValid}">
    <c:set var="useremail" value="${mailcheck.email}" scope="request" />
  <c:set var="userpassword" value="${mailcheck.password}" scope="request" />
</c:if>
<html>
<head><title>Mail validation</title></head>
<body>
<h2>Welcome to codemiles library</h2>
   
     <strong>Email</strong>:
    <c:out value="${useremail}" /><br><br>
    <strong>Password</strong>:
    <c:out value="${userpassword}" />

</body>
</html>


2. Java Class Bean
Code:


package codemiles;

/**
*
* @author codemiles
*/

public class mailchecker implements java.io.Serializable{

String email;
String password;
boolean valid;

public mailchecker()
{

    this.valid=false;
}

public boolean isValid(){

  /*  This method is called in the jsp file , here you put your code to check on
    mail , and set the value of valid property .
   */
   this.valid=true;
   return valid;
   
   }
// set the email value
public void setEmail(String _email){

     if(_email != null && _email.length() > 0)
        email = _email;
    else
         email = "Unknown";
}
// Return the current email
public String getEmail(){

    return email; }
// Set the value of the password
public void setPassword(String _password){

     if(_password != null && _password.length() > 0)
        password = _password;
    else
         password = "none";
}
// Return the value of password property
public String getPassword(){

    return password;
}

}




Post a reply
  Related Posts  to : validate mail in jsp
 validate e-mail in php     -  
 validate username     -  
 validate domain name in php     -  
 validate email address in asp     -  
 validate international phone number value     -  
 validate age entered as selection box in javascript     -  
 how to send mail with Ant     -  
 send mail using php     -  
 send mail cc and bcc in php     -  
 Help Sending e-mail from VB.Net application     -  

Topic Tags

Servlets/JSP