Total members 11892 |It is currently Sun Sep 08, 2024 4:27 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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

}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  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     -  
 php variables in mail function     -  



Topic Tags

Servlets/JSP
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com