Name

<ora:ifValidEmailAddr>

Synopsis

The <ora:ifValidEmailAddr> action tests if the specified value matches the syntax for a valid email address: only one at-sign (@), except as the first or last character, no whitespace and at least one dot after the at-sign, except as the first or last character. If so, its body is evaluated, or the Boolean test result is saved in the specified variable. Note that the validation rule isn’t always corrected; for example, on an intranet, it may be okay with just a name. It doesn’t guarantee a valid Internet email address, but it takes care of the most obvious SMTP mail address format errors.

Syntax 1: Conditionally evaluate the body

<ora:ifValidEmailAddrs value="emailAddr">
  Evaluated if the emailAddr has valid syntax
</ora:ifValidEmailAddr>

Syntax 2: Saving the test result

<ora:ifValidEmailAddr value="emailAddr" var="var" 
  [scope="page|request|session|application"] />

Attributes

Attributename

Java type

Dynamic valueaccepted

Description

value
String

EL expression

The email address to syntax validate

var
String

No

The name of the variable

scope
String

No

Scope for the variable

Example

<%-- 
  Evaluate the body if the specified email address has valid syntax
--%>
<ora:ifValidEmailAddr value="${param.email}">
  You specified a valid email address
</ora:ifValidEmailAddr>
  
<%-- 
  Save true in the isValid variable if the specified email address 
  has valid syntax
--%>
<ora:ifValidEmailAddr value="${param.email}" var="isValid" />

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.