Why this filter's code is not working right?

Hey, I have written a filter to record every request and write to a xml file. Everything works fine but the the code in filter's destroy is called twice. Don't know why? Is that there something wrong with my file writing code?? here is the code
Filter Code:
package xx;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import UserInfo;
public class RequestInspector implements Filter {
protected RequestRecorder recorder = null;
protected static String ipAddress;
protected static int hrId = -1;
public void init(FilterConfig config) {
String fileLoc = config.getInitParameter("FileLocation");
String fileName = config.getInitParameter("FileName");
ipAddress = config.getInitParameter("IPAddress");
try {
hrId = Integer.parseInt(config.getInitParameter("HRID"));
} catch (NumberFormatException nfe) {
} catch (NullPointerException npe) {
if (fileLoc != null && fileName != null && ipAddress != null && hrId != -1) {
recorder = RequestRecorder.getInstance(fileLoc, fileName);
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpSession session = httpRequest.getSession(false);
UserInfo info = ((session==null) ? null : (UserInfo)session.getAttribute("USER_INFO"));
if ( request.getRemoteAddr().equals(ipAddress) && info != null && info.getHrId() == hrId && recorder != null) {
recorder.record(httpRequest);
} // if...
chain.doFilter(request, response);
public void destroy() {
if (recorder != null) {
recorder.stop();
RequestRecorder Code
package ids.util;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import java.util.Hashtable;
import javax.servlet.http.HttpServletRequest;
public class RequestRecorder {
private static final Hashtable holder = new Hashtable(2);
private FileWriter writer = null;
private int counter = 0;
private RequestRecorder(String fileLocation, String fileName)
throws IOException {
writer = new FileWriter(new File(fileLocation, fileName));
initializeFile();
public static RequestRecorder getInstance(String fileLocation, String fileName) {
RequestRecorder recorder = null;
try {
String path = new File(fileLocation, fileName).getAbsolutePath();
recorder = (RequestRecorder) holder.get(path);
if (recorder == null) {
recorder = new RequestRecorder(fileLocation, fileName);
holder.put(path, recorder);
} catch (IOException ioe) {
return recorder;
public synchronized void record(HttpServletRequest request) throws IOException {
if (writer == null) {
return;
writer.write("\n\t\t<request path=\"" + request.getRequestURI() +"\" label=\"request" + (++counter) +"\">");
Enumeration params = request.getParameterNames();
while (params.hasMoreElements()) {
String param = (String)params.nextElement();
String[] paramValues = request.getParameterValues(param);
if (paramValues != null) {
for (int i=0; i<paramValues.length; i++) {
writer.write("\n\t\t\t<param>");
writer.write("\n\t\t\t\t<paramName>");
writer.write(param);
writer.write("</paramName>");
writer.write("\n\t\t\t\t<paramValue>");
writer.write(paramValues);
writer.write("</paramValue>");
writer.write("\n\t\t\t</param>");
} //for...
} //if...
} //while...
writer.write("\n\t\t\t<validate>");
writer.write("\n\t\t\t\t<byteLength min=\"20\" label=\"validation" + counter+"\"/>");
writer.write("\n\t\t\t</validate>");
writer.write("\n\t\t</request>");
writer.flush();
public void stop() {
if (writer != null) {
try {
finalizeFile();
writer.close();
writer = null;
} catch (IOException ioe) {
ioe.printStackTrace();
private synchronized void initializeFile() throws IOException {
writer.write("<?xml version=\"1.0\" standalone=\"no\"?>");
writer.write("\n<!DOCTYPE suite SYSTEM \"../conf/suite.dtd\">");
writer.write("\n<suite defaultHost=\"tiserver.com\" defaultPort=\"8899\" label=\"test\">");
writer.flush();
private synchronized void finalizeFile() throws IOException {
writer.write("\n\t</session>");
writer.write("\n</suite>");
writer.flush();
protected void finalize() {
stop();
}The XML output file looks like this
<?xml version="1.0" standalone="no"?>
<!DOCTYPE suite SYSTEM "../conf/suite.dtd">
<suite defaultHost="tiserver.com" defaultPort="8899" label="test">
<request path="/acfrs/loginP.jsp" label="Login">
<param>
<paramName>userId</paramName>
<paramValue>redfsdf</paramValue>
</param>
<param>
<paramName>passWord</paramName>
<paramValue>h1dffd3dfdf</paramValue>
</param>
<validate>
<regexp pattern="Invalid Login" cond="false" ignoreCase="true" label="Login Check"/>
</validate>
</request>
</session>
</suite>frs/left_frame.jsp" label="request1">
<validate>
<byteLength min="20" label="validation1"/>
</validate>
</request>
<request path="/acfrs/welcome.jsp" label="request2">
<validate>
<byteLength min="20" label="validation2"/>
</validate>
</session>
</suite>
If you closely observe the XML file "</session> </suite>" is written in the middle of the file too. Why does this happen? By the way, this code works perfectly on my windows desktop but on unix server the above problem turns up. Any clues??
Thanks

Ooops! The finalize() method in RequestRecorder is redundant. Mistakenly uncommnented it (finalize() method code ) while posting it here :-)

Similar Messages

  • Why this simple IF - ENDIF is NOT working??

    Hi Experts,
    Am wrting a simple  IF condition with WILD CARD value , in the user exit, as below,
    if xlikp-lgbzo = 'AB'. (pls. notice that, there is WILD CARD in the 'AB' value)
    sy-subrc = 0.
    else.
    sy-subrc = 4.
    endif.
    1) Say, the XLIKP-LGBZO value = AB-01-02 (pls. notice that, there  ' - ' in the value of AB-01-02)
    then, sy-subrc is becoming 4 ?????????????
    2 )Say, the XLIKP-LGBZO value = ZB-01-02
    then, sy-subrc is becoming 4
    the 2nd case is OK, but, Why the 1st case is becoming FALSE?? actuallym it shuld b TRUE, right??
    Is it bcoz of hiphans -  " - "?? but, i tried with WITH OUT hiphans , then also NOT working CORRECTLY??
    thanq

    Hi Srini,
    Try the following:
    IF XLIKP-LGBZO  CP 'AB*'.
    sy-subrc = 0.
    ELSE.
    sy-subrc = 4.
    ENDIF.
    CP - Contains Pattern
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • Why this simple 'IF' syntax is not working?

    Hello
    Pls. help me that,
    var myObject = /TextField11/
    var greyFieldsList = "TextFieldAA TextFieldBB TextFieldCC "
    var ReqFieldsList = "TextField11 TextField22 TextField33 "
    var returnValue = greyFieldsList.search(myObject);
    var returnValueReq = ReqFieldsList.search(myObject);
    if (returnValue != -1) {
    this.fillColor = "192,192,192"; //GREY
    this.access    = "readOnly";
    else if (returnValueReq != -1)
    this.fillColor = "255,255,191";  //YELLOW
    else
    // do nothing
    Yellow is not working at all!!
    Grey is working some times, some times not!
    Pls. correct my IF condition in such a way it shoud work.
    At given point of time, any field possess only one color
    Thank you

    Hi Srini,
    Try the following:
    IF XLIKP-LGBZO  CP 'AB*'.
    sy-subrc = 0.
    ELSE.
    sy-subrc = 4.
    ENDIF.
    CP - Contains Pattern
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • Why this code is not working??? java script

    gen_validatorv2.js
         JavaScript Form Validator
    Version 2.0.2
         Copyright 2003 JavaScript-coder.com. All rights reserved.
         You use this script in your Web pages, provided these opening credit
    lines are kept intact.
         The Form validation script is distributed free from JavaScript-Coder.com
         You may please add a link to JavaScript-Coder.com,
         making it easy for others to find this script.
         Checkout the Give a link and Get a link page:
         http://www.javascript-coder.com/links/how-to-link.php
    You may not reprint or redistribute this code without permission from
    JavaScript-Coder.com.
         JavaScript Coder
         It precisely codes what you imagine!
         Grab your copy here:
              http://www.javascript-coder.com/
    function Validator(frmname)
    this.formobj=document.forms[frmname];
         if(!this.formobj)
         alert("BUG: couldnot get Form object "+frmname);
              return;
         if(this.formobj.onsubmit)
         this.formobj.old_onsubmit = this.formobj.onsubmit;
         this.formobj.onsubmit=null;
         else
         this.formobj.old_onsubmit = null;
         this.formobj.onsubmit=form_submit_handler;
         this.addValidation = add_validation;
         this.setAddnlValidationFunction=set_addnl_vfunction;
         this.clearAllValidations = clear_all_validations;
    function set_addnl_vfunction(functionname)
    this.formobj.addnlvalidation = functionname;
    function clear_all_validations()
         for(var itr=0;itr < this.formobj.elements.length;itr++)
              this.formobj.elements[itr].validationset = null;
    function form_submit_handler()
         for(var itr=0;itr < this.elements.length;itr++)
              if(this.elements[itr].validationset &&
         !this.elements[itr].validationset.validate())
              return false;
         if(this.addnlvalidation)
         str =" var ret = "+this.addnlvalidation+"()";
         eval(str);
    if(!ret) return ret;
         return true;
    function add_validation(itemname,descriptor,errstr)
    if(!this.formobj)
         alert("BUG: the form object is not set properly");
              return;
         }//if
         var itemobj = this.formobj[itemname];
    if(!itemobj)
         alert("BUG: Couldnot get the input object named: "+itemname);
              return;
         if(!itemobj.validationset)
         itemobj.validationset = new ValidationSet(itemobj);
    itemobj.validationset.add(descriptor,errstr);
    function ValidationDesc(inputitem,desc,error)
    this.desc=desc;
         this.error=error;
         this.itemobj = inputitem;
         this.validate=vdesc_validate;
    function vdesc_validate()
    if(!V2validateData(this.desc,this.itemobj,this.error))
    this.itemobj.focus();
              return false;
    return true;
    function ValidationSet(inputitem)
    this.vSet=new Array();
         this.add= add_validationdesc;
         this.validate= vset_validate;
         this.itemobj = inputitem;
    function add_validationdesc(desc,error)
    this.vSet[this.vSet.length]=
         new ValidationDesc(this.itemobj,desc,error);
    function vset_validate()
    for(var itr=0;itr<this.vSet.length;itr++)
         if(!this.vSet[itr].validate())
              return false;
         return true;
    function validateEmailv2(email)
    // a very simple email validation checking.
    // you can add more complex email checking if it helps
    if(email.length <= 0)
         return true;
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    var regexp_user=/^\"?[\w-_\.]*\"?$/;
    if(splitted[1].match(regexp_user) == null) return false;
    if(splitted[2] != null)
    var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
    if(splitted[2].match(regexp_domain) == null)
         var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
         if(splitted[2].match(regexp_ip) == null) return false;
    }// if
    return true;
    return false;
    function V2validateData(strValidateStr,objValue,strError)
    var epos = strValidateStr.search("=");
    var command = "";
    var cmdvalue = "";
    if(epos >= 0)
    command = strValidateStr.substring(0,epos);
    cmdvalue = strValidateStr.substr(epos+1);
    else
    command = strValidateStr;
    switch(command)
    case "req":
    case "required":
    if(eval(objValue.value.length) == 0)
    if(!strError || strError.length ==0)
    strError = objValue.name + " : Required Field";
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case required
    case "maxlength":
    case "maxlen":
    if(eval(objValue.value.length) > eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : "+cmdvalue+" characters maximum ";
    }//if
    alert(strError + "\n[Current length = " + objValue.value.length + " ]");
    return false;
    }//if
    break;
    }//case maxlen
    case "minlength":
    case "minlen":
    if(eval(objValue.value.length) < eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : " + cmdvalue + " characters minimum ";
    }//if
    alert(strError + "\n[Current length = " + objValue.value.length + " ]");
    return false;
    }//if
    break;
    }//case minlen
    case "alnum":
    case "alphanumeric":
    var charpos = objValue.value.search("[^A-Za-z0-9]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": Only alpha-numeric characters allowed ";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if
    break;
    }//case alphanumeric
    case "num":
    case "numeric":
    var charpos = objValue.value.search("[^0-9]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": Only digits allowed ";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if
    break;
    }//numeric
    case "alphabetic":
    case "alpha":
    var charpos = objValue.value.search("[^A-Za-z]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": Only alphabetic characters allowed ";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if
    break;
    }//alpha
              case "alnumhyphen":
    var charpos = objValue.value.search("[^A-Za-z0-9\-_]");
    if(objValue.value.length > 0 && charpos >= 0)
    if(!strError || strError.length ==0)
    strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _";
    }//if
    alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
    return false;
    }//if                
                   break;
    case "email":
    if(!validateEmailv2(objValue.value))
    if(!strError || strError.length ==0)
    strError = objValue.name+": Enter a valid Email address ";
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case email
    case "lt":
    case "lessthan":
    if(isNaN(objValue.value))
    alert(objValue.name+": Should be a number ");
    return false;
    }//if
    if(eval(objValue.value) >= eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : value should be less than "+ cmdvalue;
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case lessthan
    case "gt":
    case "greaterthan":
    if(isNaN(objValue.value))
    alert(objValue.name+": Should be a number ");
    return false;
    }//if
    if(eval(objValue.value) <= eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name + " : value should be greater than "+ cmdvalue;
    }//if
    alert(strError);
    return false;
    }//if
    break;
    }//case greaterthan
    case "regexp":
                   if(objValue.value.length > 0)
         if(!objValue.value.match(cmdvalue))
         if(!strError || strError.length ==0)
         strError = objValue.name+": Invalid characters found ";
         }//if
         alert(strError);
         return false;
         }//if
    break;
    }//case regexp
    case "dontselect":
    if(objValue.selectedIndex == null)
    alert("BUG: dontselect command for non-select Item");
    return false;
    if(objValue.selectedIndex == eval(cmdvalue))
    if(!strError || strError.length ==0)
    strError = objValue.name+": Please Select one option ";
    }//if
    alert(strError);
    return false;
    break;
    }//case dontselect
    }//switch
    return true;
         Copyright 2003 JavaScript-coder.com. All rights reserved.
    example.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Example for Validator</title>
    <script language="JavaScript" src="gen_validatorv2.js" type="text/javascript"></script>
    </head>
    <body>
    <form action="" name="myform" >
    <table cellspacing="2" cellpadding="2" border="0">
    <tr>
    <td align="right">First Name</td>
    <td><input type="text" name="FirstName"></td>
    </tr>
    <tr>
    <td align="right">Last Name</td>
    <td><input type="text" name="LastName"></td>
    </tr>
    <tr>
    <td align="right">EMail</td>
    <td><input type="text" name="Email"></td>
    </tr>
    <tr>
    <td align="right">Phone</td>
    <td><input type="text" name="Phone"></td>
    </tr>
    <tr>
    <td align="right">Address</td>
    <td><textarea cols="20" rows="5" name="Address"></textarea></td>
    </tr>
    <tr>
    <td align="right">Country</td>
    <td>
         <SELECT name="Country">
              <option value="" selected>[choose yours]
              <option value="008">Albania
              <option value="012">Algeria
              <option value="016">American Samoa
              <option value="020">Andorra
              <option value="024">Angola
              <option value="660">Anguilla
              <option value="010">Antarctica
              <option value="028">Antigua And Barbuda
              <option value="032">Argentina
              <option value="051">Armenia
              <option value="533">Aruba     
         </SELECT>
         </td>
    </tr>
    <tr>
    <td align="right"></td>
    <td><input type="submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    <script language="JavaScript" type="text/javascript">
    //You should create the validator only after the definition of the HTML form
    var frmvalidator = new Validator("myform");
    frmvalidator.addValidation("FirstName","req","Please enter your First Name");
    frmvalidator.addValidation("FirstName","maxlen=20",
         "Max length for FirstName is 20");
    frmvalidator.addValidation("FirstName","alpha");
    frmvalidator.addValidation("LastName","req");
    frmvalidator.addValidation("LastName","maxlen=20");
    frmvalidator.addValidation("Email","maxlen=50");
    frmvalidator.addValidation("Email","req");
    frmvalidator.addValidation("Email","email");
    frmvalidator.addValidation("Phone","maxlen=50");
    frmvalidator.addValidation("Phone","numeric");
    frmvalidator.addValidation("Address","maxlen=50");
    frmvalidator.addValidation("Country","dontselect=0");
    </script>
    </body>
    </html>
    documentation.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
         <title>JavaScript Form Validator Documentation</title>
    <Style>
    BODY, P,TD{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 10pt }
    H1{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 18pt; color : #000066}
    H3{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 12pt; color : #000066 }
    A{font-family: Arial,Verdana,Helvetica, sans-serif;}
    B {     font-family : Arial, Helvetica, sans-serif;     font-size : 12px;     font-weight : bold;}
    CODE {font-family : Courier,monospace;font-size: 10pt;color : #800000;}
    CODE.htm {font-family : "Courier New", Courier, monospace;     font-size : x-small;     color : #000080;}
    </Style>
    </head>
    <body>
    <center>
    <table cellspacing="2" cellpadding="2" border="0" width="600">
    <tr><td>
         <h1>JavaScript Form Validations Made Easy!</h1>
         <h3>Documentation for JavaScript Form Validator</h3>
         <HR size=1>
         <P>
         The Form validation script is distributed free from JavaScript-Coder.com<br>
         You can use the script in your web pages for free.
         </P>
         <P>
         You may please add a link to JavaScript-Coder.com,
         making it easy for others to find this script.<br>
         Checkout the <A href="http://www.javascript-coder.com/links/how-to-link.php
         target="_blank">Give a Link & Get a Link!</A> page.
         </P>
         <P>
         <B>JavaScript Coder</B><br>
         It precisely codes what you imagine!<br>
         Grab your copy here: http://www.javascript-coder.com
         </P>
         <HR size=1>
         <P>
         Using client side JavaScript is an efficient way to validate the user input
         in web applications. When there are many fields in the form, the JavaScript
         validation becomes too complex.
         </P>
         <P>
    The JavaScript class presented here makes the form validations many times easier.
         </P>
         <P>
         The idea is to create a set of "validation descriptors" associated with each element
         in a form. The "validation descriptor" is nothing but a string specifying the type of
         validation to be performed.
         </P>
         <P>
         Each field in the form can have 0, 1, or more validations. For example, the input should
         not be empty, should be less than 25 chars, should be alpha-numeric, etc
         </P>
         You can associate a set of validation descriptors for each input field in the form.
         <a name="3"></a>
         <h3>Using The Script</h3>
         1.Include gen_validatorv2.js in your html file just before closing the HEAD tag<br><br>
         <CODE>
         <script language="JavaScript" src="gen_validatorv2.js" type="text/javascript"></script><BR>
         </head><BR>
         </CODE><br>
         2. Just after defining your form,
         Create a form validator object passing the name of the form<br><br>
         <CODE class='htm'>
          <FORM name='myform' action=""><BR>
          <!----Your input fields go here --><BR>
          </FORM><BR>
         </CODE><CODE>
          <SCRIPT language="JavaScript"><BR>
          var frmvalidator  = new Validator("myform");<BR>
         </CODE>
         <br>
         <br>
         3. Now add the validations required<br><br>
         <CODE>
              frmvalidator.addValidation("FirstName","alpha");
         </CODE><br><br>
         the first argument is the name of the field and the second argument is the
         validation descriptor, which specifies the type of validation to be performed.<br>
         You can add any number of validations.The list of validation descriptors are provided
         at the end of the documentation.<br>
         The optional third argument is the error string to be displayed if the validation
         fails.<br>
         <br>
         <CODE>
              frmvalidator.addValidation("FirstName","alpha");<br>
              frmvalidator.addValidation("FirstName","req","Please enter your First Name");<br>
              frmvalidator.addValidation("FirstName","maxlen=20",<br>
                   "Max length for FirstName is 20");          <br>
         </CODE>     <br>
         <br>
         4. Similarly, add validations for the fields where validation is required.<br>
         That's it! You are ready to go.
         <A name="3"></A>
         <h3>Example</h3>
         The example below will make the idea clearer<br>
         <CODE class="htm">
                   <form action="" name="myform" ><BR>
                   <table cellspacing="2" cellpadding="2" border="0"><BR>
                   <tr><BR>
                     <td align="right">First Name</td><BR>
                     <td><input type="text" name="FirstName"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Last Name</td><BR>
                     <td><input type="text" name="LastName"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">EMail</td><BR>
                     <td><input type="text" name="Email"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Phone</td><BR>
                     <td><input type="text" name="Phone"></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Address</td><BR>
                     <td><textarea cols="20" rows="5" name="Address"></textarea></td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right">Country</td><BR>
                     <td><BR>
                          <SELECT name="Country"><BR>
                             <option value="" selected>[choose yours]<BR>
                             <option value="008">Albania<BR>
                             <option value="012">Algeria<BR>
                             <option value="016">American Samoa<BR>
                             <option value="020">Andorra<BR>
                             <option value="024">Angola<BR>
                             <option value="660">Anguilla<BR>
                             <option value="010">Antarctica<BR>
                             <option value="028">Antigua And Barbuda<BR>
                             <option value="032">Argentina<BR>
                             <option value="051">Armenia<BR>
                             <option value="533">Aruba     <BR>
                         </SELECT><BR>
                        </td><BR>
                   </tr><BR>
                   <tr><BR>
                     <td align="right"></td><BR>
                     <td><input type="submit" value="Submit"></td><BR>
                   </tr><BR>
                   </table><BR>
                   </form><BR>
                   </CODE><CODE>
                   <script language="JavaScript" type="text/javascript"><BR>
                    var frmvalidator = new Validator("myform");<BR>
                    frmvalidator.addValidation("FirstName","req","Please enter your First Name");<BR>
                    frmvalidator.addValidation("FirstName","maxlen=20",<BR>
                        "Max length for FirstName is 20");<BR>
                    frmvalidator.addValidation("FirstName","alpha");<BR>
                    <BR>
                    frmvalidator.addValidation("LastName","req");<BR>
                    frmvalidator.addValidation("LastName","maxlen=20");<BR>
                    <BR>
                    frmvalidator.addValidation("Email","maxlen=50");<BR>
                    frmvalidator.addValidation("Email","req");<BR>
                    frmvalidator.addValidation("Email","email");<BR>
                    <BR>
                    frmvalidator.addValidation("Phone","maxlen=50");<BR>
                    frmvalidator.addValidation("Phone","numeric");<BR>
                    <BR>
                    frmvalidator.addValidation("Address","maxlen=50");<BR>
                    frmvalidator.addValidation("Country","dontselect=0");<BR>
                   </script><BR>     
         </CODE>
         <A name="4"></A>
         <h3>Some Additional Notes</h3>
         <LI type="disc">The form validators should be created only after defining the HTML form
         (only after the </form> tag. )<br>
         <LI type="disc">Your form should have a distinguished name.
         If there are more than one form
         in the same page, you can add validators for each of them. The names of the
         forms and the validators should not clash.
         <LI type="disc">You can't use the javascript onsubmit event of the form if it you are
         using this validator script. It is because the validator script automatically overrides the
         onsubmit event. If you want to add a custom validation, see the section below
         </LI>
         <A name="5"></A>
         <h3>Adding Custom Validation</h3>
         If you want to add a custom validation, which is not provided by the validation descriptors,
         you can do so. Here are the steps:
         <LI type="disc">Create a javascript function which returns true or false depending on the validation.<br>
         <CODE>
              function DoCustomValidation()<BR>
              {<BR>
                var frm = document.forms["myform"];<BR>
                if(frm.pwd1.value != frm.pwd2.value)<BR>
                {<BR>
                  alert('The Password and verified password does not match!');<BR>
                  return false;<BR>
                }<BR>
                else<BR>
                {<BR>
                  return true;<BR>
                }<BR>
              }<BR>
         </CODE><br>
         <LI type="disc">Associate the validation function with the validator object.<br>
         <CODE>
         frmvalidator.setAddnlValidationFunction("DoCustomValidation");
         </CODE><br>
         </LI>
         <P>
         The custom validation function will be called automatically after other validations.
         </P>
         <P>
         If you want to do more than one custom validations, you can do all those
         validations in the same function.
         </P>
         <CODE>
              function DoCustomValidation()<BR>
              {<BR>
                var frm = document.forms["myform"];<BR>
                if(false == DoMyValidationOne())<BR>
                {<BR>
                  alert('Validation One Failed!');<BR>
                  return false;<BR>
                }<BR>
                else<BR>
                if(false == DoMyValidationTwo())<BR>
                {<BR>
                  alert('Validation Two Failed!');<BR>
                  return false;<BR>
                }<BR>
                else<BR>
                {<BR>
                  return true;<BR>
                }<BR>
              }<BR>
         </CODE><br>
         where DoMyValidationOne() and DoMyValidationTwo() are custom functions for
         validation.
         <A name="6"></A>
         <h3>Clear All Validations</h3>
         In some dynamically programmed pages, it may be required to change the validations in the
         form at run time. For such cases, a function is included which clears all validations in the
         validator object.<br><br>
         <CODE>
         frmvalidator.clearAllValidations();
         </CODE><br>
         <br>
         this function call clears all validations you set.<br>
         You will not need this method in most cases.
         <a name="7"></a>
         <h3>Table of Validation Descriptors</h3>     
    <table cellspacing="2" cellpadding="2" border="1" width="520px">
    <tr>
    <td><FONT face=Arial size=2>
         required<BR>
         req </FONT>
         </td>
    <td><FONT face=Arial size=2>The field should not be
    empty </FONT>
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>
         maxlen=???<BR>
         maxlength=???
         </td>
    <td><FONT face=Arial size=2>checks the length entered data to the maximum. For
    example, if the maximum size permitted is 25, give the validation descriptor as "maxlen=25"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>
         minlen=???<BR>
         minlength=???
         </td>
    <td><FONT face=Arial size=2>checks the length of the entered string to the
    required minimum. example "minlen=5"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>
         alphanumeric /<BR>
         alnum </FONT>
         </td>
    <td><FONT face=Arial size=2>Check the data if it
    contains any other characters other than alphabetic or numeric characters
    </FONT>
         </td>
    </tr>     
    <tr>
    <td><FONT face=Arial size=2>num <BR>
         numeric </FONT>
         </td>
    <td><FONT face=Arial size=2>Check numeric data
    </FONT>
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>alpha <BR>
         alphabetic </FONT>
         </td>
    <td><FONT face=Arial size=2>Check alphabetic data.
    </FONT>
         </td>
    </tr>     
    <tr>
    <td><FONT face=Arial size=2>email </FONT>
         </td>
    <td><FONT face=Arial size=2>The field is an email
    field and verify the validity of the data. </FONT>
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>lt=???<BR>
         lessthan=???
         </td>
    <td><FONT face=Arial size=2>
         Verify the data to be less than the value passed.
         Valid only for numeric fields. <BR>
         example: if the
    value should be less than 1000 give validation description as "lt=1000"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>gt=???<BR>
         greaterthan=???     </td>
    <td><FONT face=Arial size=2>
         Verify the data to be greater than the value passed.
         Valid only for numeric fields. <BR>
         example: if the
    value should be greater than 10 give validation description as "gt=10"
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>regexp=??? </FONT>
         </td>
    <td><FONT face=Arial size=2>
         Check with a regular expression the value should match the regular expression.<BR>
         example: "regexp=^[A-Za-z]{1,20}$" allow up to 20 alphabetic
         characters.
         </td>
    </tr>
    <tr>
    <td><FONT face=Arial size=2>dontselect=?? </FONT>
         </td>
    <td><FONT face=Arial size=2>This
    validation descriptor is valid only for select input items (lists)
    Normally, the select list boxes will have one item saying 'Select One' or
    some thing like that. The user should select an option other than this
    option. If the index of this option is 0, the validation description
    should be "dontselect=0"
         </td>
    </tr>
    </table>
         <P>
              <table cellspacing="2" cellpadding="2" border="1" width="520">
              <tr>
              <td>
                   <B>NOTE:</B><br>
                   The HTML Form Wizard included in JavaScript Coder contains still more
                   number of validations
                   (comparison validations, check box & radio button validations and more)<br>
                   Using the wizard, you can add validations to your forms
                   without writing a single line of code! <br>
                   JavaScript Coder takes care of
                   generating the code and inserting the code in to the HTML file.<br>
                   <A href="http://www.javascript-coder.com/index.phtml
                   target="_blank">Read more about JavaScript Coder</A>
                   </td>
              </tr>
              </table>
         </P>
         <A name="8"></A>
         <h3>Example Page</h3>     
         See the <a href="example.html target="_blank"
         >JavaScript form validation example here</a>
    </td>
    </tr>
    <tr><td align="center">
         <HR><br>
         Copyright &copy; 2003 JavaScript-Coder.com. All rights reserved.
    </td></tr>
    </table>     
    </center>
    </body>
    </html>

    The code is not working because you made a mistake somewhere, duh! So figure out what (hint: firefox javascript console, it's your friend) and fix it!
    And next time when you post code: use the [ code ]  tags to pretty format your code, as it is now it's unreadable.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • I am trying ot install my cs6 online. it says that my code has been redeemed but i took it off of one of my laptops to download it onto this one. it is still not working. please help

    I am trying ot install my cs6 online. it says that my code has been redeemed but i took it off of one of my laptops to download it onto this one. it is still not working. please help

    Find your serial number quickly
    Download CS6 products
    Activation & Deactivation Help
    Mylenium

  • In outlook 2013 Add-In, Adding dynamic menu to splitButton idMso="DialMenu" is working and the same code is not working in outlook 2010 Add-In.

    In outlook 2013 Add-In, Adding dynamic menu to <splitButton idMso="DialMenu"> is working and the same code is not working in outlook
    2010 Add-In. please let me know, if i am missing something. Below is the xml and screen shot
    <contextMenu idMso="ContextMenuFlaggedContactItem">
     <splitButton idMso="DialMenu">
              <menu>
                <dynamicMenu id="CallContactwithFreedomvoice
    " label="CallContactwithFreedomvoice" 
                            getContent="OnGetContenttest"                           insertAfterMso="Call"/> 
            </menu>       </splitButton>    </contextMenu> 

    Hi Narasimha prasad2,
    Based on the description, the context menu for the flagged contact doen't work in Outlook. I am tring to rerpoduce this issue however failed.
    I suggest that you check the state of the add-in first to see wether the add-in was loaded successfully.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I am unable to get into my IPhone.  My 4 digit code is not working and my cell is disabled. I've tried connecting to iTunes to do a reset to factory default however I need the password (my 4 digit code) help!! I've been without my iPhone for 2 days.

    I'm locked out of my iPhone.   My 4 digit security code is not working.  I've tried to connect to iTunes to do a recovery however I. Order to do this it asks me for the 4 digit code.  I need to reset it but unable to get into reset as well.  Help!!t can I reset it using my iPad which is registered to the same account

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...  Be sure to Follow ALL the Steps..

  • Why is my apple ID password not working on ipad2 after updating to iOS6?

    Why is my apple ID password not working after upgrading to iOS6?

    Who knows?
    Settings>iTunes and App Stores>Tap your ID and sign out. Reboot your iPad.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Go back to the settings and sign back in again and see of it works now.
    If it doesn't work, post back with some information that might help us help you. Describe what you are doing in some detail and it might let us better understand why this is happening.

  • My redemption cod is not working so I cannot obtain my serial number. What am I supposed to do now?

    My redemption code is not working so I cannot obtain my serial number. What am I supposed to do now?

    hello, other users with this problem all had an embedded intel hd3000 graphics card with an old driver present. in case this also applies to you, here would be a link to update the driver, which in turn should also address the black firefox problem: https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=23764 (for win7 64 bit)

  • Why Does Live View In DW Not Work With BC Template?

    The live view using a BC template in DW CS6 shows "PAGE NOT FOUND" in the body section but the header and footer look fine. I should also point out that the index.htm page works fine, it's just the other pages that have this problem. What makes it weirder is that the site works fine in all other modes including when viewing in a normal browser, it's ONLY when in live view! I also noticed that if I delete the .htm extension in the url in the DW browser when in Live View it fixes the problem, but this requires me to do this everytime I want to switch to live view and surely is either a problem with how the BC template files are named or DW CS6 is buggy? Hopefully this is an easy one to answer??

    Hi Alex,
    Thanks for your reply, I have done a video demo at http://screencast.com/t/RsutrvoFn0xZ
    Date: Thu, 14 Feb 2013 05:49:55 -0800
    From: [email protected]
    To: [email protected]
    Subject: Why Does Live View In DW Not Work With BC Template?
        Re: Why Does Live View In DW Not Work With BC Template?
        created by Alex Pavelescu in Dreamweaver & Business Catalyst - View the full discussion
    Hi, Please provide the site url, and if you can, a video demo of the issue you're facing, using http://www.techsmith.com/jing.html, where you could also display the way you have your side setup ( Dreamweaver menu > Site > Site manager > http://screencast.com/t/GqqBk9MY4ck ) Kind Regards,Alex
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5072585#5072585
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5072585#5072585
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5072585#5072585. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver & Business Catalyst by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Typing special (alt + four number code) characters not working?

    For many foreign language and dingbat fonts, a large number of special characters can be accessed only by typing the unicode symbol: hold down ALT and type a four-digit code.
    For some reason, under Leopard, typing the four-digit code just gets me the "bonk bonk" error sound and no special characters.
    Short of spending $50 on software made to browse unicode (like PopChar X), how can I type special characters under Leopard?

    Short of spending $50 on software made to browse unicode (like PopChar X), how can I type special characters under Leopard?
    Normally one would use Character Palette (Edit > Special Characters) or an alternative language keyboard layout (system prefs/international/input menu). The Unicode Hex layout and typing Option/Alt plus the Unicode hex number would be the last choice.
    What app are you trying to do this in? Some non-Apple apps might not work right. Also don't forget to hold down the Option/alt key while you type the numbers.
    If you do not get the Character Palette when you do Edit > Special Characters, the fix is:
    http://support.apple.com/kb/TS1896?viewlocale=en_US
    If there are certain characters you need all the time, let us know what they are and we might be able to suggest a custom keyboard layout.

  • I have original windows vista activation code is not working

    i have original windows vista,but the activation code is not working on computer why?

    Troubleshoot activation problems
    Carey Frisch

  • Removing _root code does not work

    I've tried removing or using this and code dose not work. Any help is appreciated.
    var j:Number;
    for (j = 0; j < 7; j++) {
    _root["holder_mc"+j].onPress = function() {
    with(this){
        startDrag(false);
           lineStyle(3,0xcccccc,100);
          lineTo(_root.myWidth,0);
           lineTo(_root.myWidth,_root.myHeight);
           lineTo(0,_root.myHeight);
           lineTo(0,0);

    I used:
    eval("holder_mc"+j).onPress = function()

  • Code hints not working in Flash CC

    I just downloaded the Flash CC trial and have been looking at the forums but I can't get code hints to work at all, when I begin to type a line I get "Building code hint cache" in bottom right of Actions panel with a warning icon - no more info available, no tool tip on rollover it apparently does nothing.
    I've looked for this problem in the forums and found many references to code hints not working and have tried all the support recommendations for deleting the CodeModel file, resetting preferences, deleting preferences, checking and unchecking preferences, changing the file cap in the registry and nothing seems to work - still no code hints at all.
    I'm on a windows 8 machine, I don't know if that has anything to do with it.

    SujaiS wrote:
    Hi Beadicakes,
    Have you saved your .as file  on the desktop of any common location with a large set of files? 
    -Sujai
    Hello Friends. I create simple button and when try to write simple addEventListener code hint don't work properly. I.e. when I write "Button1." code hint window don't popup. And when save project, only fla file have saved. No as files have saved.  Where is the location of the 'as' file??? This is the code of as3 file
    import flash.display.SimpleButton;
    import flash.events.Event;
    import flash.events.MouseEvent;
    Button1.addEventListener(MouseEvent.MOUSE_DOWN,go);
    function go(Event:MouseEvent):void
    trace("sdfsdfd");

  • Why does my digital AV adapter not work with my iPad

    Why does my digital AV adapter not work with my iPad

    i was going to try it on a flat screen hdmi input, but just as i plug the apple digital av adapter in to my ipad it says "this accessory is not supported by ipad"... my itouch says the same thing... any ideas?

Maybe you are looking for

  • Any way to reduce class file size?

    Somewhere during my travels on the net I remember seeing something about a utility that reduces the size of java class files, eg by optimizing. I think it is an IBM product. Anybody know about this? I am writing a midlet that needs to be less than 70

  • Java applet won't load from Jar file

    Hi all, I have a problem which I didn't used to have. I have written an applet which used certain classes stored in directories. It used to work just fine. I recently updated the main class from which the applet starts and since then I get error mess

  • Bulk change of calendar items

    I had this sync problem with my Palm, and ended up with all of my appointments going into the Unfiled calendar. I want most of them to be in my business calendar. Is there a reasonably easy way to select a lot of them and tell it to change them all a

  • Odd Migration from (CorporateTime) 5.0 via 5.4 to 10.1.1.0.2 /A.06.10

    There's a support document that states, that for upgrading from 5.0 to something supported I have to migrate to 5.4 first. I couldn't find this version for download and I'ld like to know if it's possible to get that version, just for the sake of migr

  • Dailup speed very slow

    We live in a rural area where we can not yet get high speed (except Hughes...too expensive--Wild Blue sold out of bandwidth--no one close enough for wireless yet). My dialup worked fine on my Mac until I attempted to setup a mixed Mac/PC 'network' by