Email class
package com.baozi;
import java.io.Serializable;
public class Email implements Serializable{
private static final long serialVersionUID = 1L;
private String mailAdd;
private boolean email;
public Email(){}
public Email(String mailAdd){
this.mailAdd=mailAdd;
}
public boolean IsEmail(){
String Regex="\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
if(mailAdd.matches(Regex))
email=true;
else
email= false;
return email;
}
public String getMailAdd() {
return mailAdd;
}
public void setMailAdd(String mailAdd) {
this.mailAdd = mailAdd;
}
}
index.jsp
pageEncoding="gb2312" isErrorPage="true"%>
Email Check邮箱检查 | |
邮箱地址: | |
result.jsp
pageEncoding="gb2312"%>
Show ResultString mailAdd=request.getParameter("mailAdd");
Email email=new Email(mailAdd);
if(email.IsEmail())
out.println(mailAdd+"
是一个标准的Email地址");
else
out.println(mailAdd+"
不是一个标准的Email地址");
%>