Bug in IIS 5.1 JScript - undefined strings from Request object

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Bug in IIS 5.1 JScript - undefined strings from Request object

    Hi All!

    I have checked Windows Script help for the Undefined Data Type. It says I
    should be able to do this:
    // This method will work
    if (typeof(x) == "undefined")
    // do something

    However, I have found that when I try to get something from Session and
    Request that does not exist, the object coming back from each is different
    when they should both be undefined.

    My simple test:

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    <html>
    <body>
    reallyNotThere: &quot;<%= Session("reallyNotThere") %>&quot;<br>
    reallyNotThere2: &quot;<%= Request("reallyNotThere2") %>&quot;<br>
    <%
    var reallyNotThere = Session ("reallyNotThere");
    Response.Write("<br>Not there &quot;" + reallyNotThere + "&quot;")
    if (typeof(reallyNotThere) == "undefined")
    {
    Response.Write("<br>it is not there!");
    }
    else
    {
    Response.Write("<br>it is there");
    }

    var reallyNotThere2 = Request("reallyNotThere2");
    Response.Write("<br>Not there 2 &quot;" + reallyNotThere2 +
    "&quot;")
    if (typeof(reallyNotThere2) == "undefined")
    {
    Response.Write("<br>it is not there!");
    }
    else
    {
    Response.Write("<br>it is there");
    }
    %>
    </body>
    </html>


    The output:

    reallyNotThere: ""
    reallyNotThere2: ""

    Not there "undefined"
    it is not there!
    Not there 2 "undefined"
    it is there



    If
    (typeof(reallyNotThere) == "undefined")
    is true, so should
    (typeof(reallyNotThere2) == "undefined")

    Rob
    :)


    Robert Mark Bram Guest

  2. Similar Questions and Discussions

    1. Element LOCALE is undefined in REQUEST.
      Hello all, After installing ColdFusion MX 7, I followed the tutorial but when I try to preview the page I got this error message: ...
    2. SQLEXECUTIVE is undefined in REQUEST
      Hi desperate plea.. :D I completed my project for uni about 2 weeks ago.. I have a demonstration of it in two weeks and was just about to prepare...
    3. Error: Element LOCALE is undefined in REQUEST.
      Hello, I recently installed Coldfusion 7 to begin learning the code in preparation for a high school assignment and I've already run into some...
    4. Element LOCALE is undefined in REQUEST.?
      :) Hi guys. I posted the "point 9 page 28" comment. Glad to see it's not just me. Prayank's solution does indeed work. Thanks for the help.
    5. Solution to REQUEST.LOCALE undefined error in ARTgallery tutorial
      Thanks. We really should fix this. I've added your comment to the bug notes. The bug number is 59867. Ted Zimmerman
  3. #2

    Default Re: Bug in IIS 5.1 JScript - undefined strings from Request object

    I think the difference is that Session("reallyNotThere") returns null
    and Request("reallyNotThere2") returns an empty string.

    Try Response.Write(typeof(reallyNotThere) + " - " +
    typeof(reallyNotThere2)), if I am correct it should display "undefined
    - object".

    -Wagner

    "Robert Mark Bram" <relaxedrob@removethis.optushome.com.au> wrote in message news:<3f8fd73a$0$24674$afc38c87@news.optusnet.com. au>...
    > Hi All!
    >
    > I have checked Windows Script help for the Undefined Data Type. It says I
    > should be able to do this:
    > // This method will work
    > if (typeof(x) == "undefined")
    > // do something
    >
    > However, I have found that when I try to get something from Session and
    > Request that does not exist, the object coming back from each is different
    > when they should both be undefined.
    >
    > My simple test:
    >
    > <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    > <html>
    > <body>
    > reallyNotThere: &quot;<%= Session("reallyNotThere") %>&quot;<br>
    > reallyNotThere2: &quot;<%= Request("reallyNotThere2") %>&quot;<br>
    > <%
    > var reallyNotThere = Session ("reallyNotThere");
    > Response.Write("<br>Not there &quot;" + reallyNotThere + "&quot;")
    > if (typeof(reallyNotThere) == "undefined")
    > {
    > Response.Write("<br>it is not there!");
    > }
    > else
    > {
    > Response.Write("<br>it is there");
    > }
    >
    > var reallyNotThere2 = Request("reallyNotThere2");
    > Response.Write("<br>Not there 2 &quot;" + reallyNotThere2 +
    > "&quot;")
    > if (typeof(reallyNotThere2) == "undefined")
    > {
    > Response.Write("<br>it is not there!");
    > }
    > else
    > {
    > Response.Write("<br>it is there");
    > }
    > %>
    > </body>
    > </html>
    >
    >
    > The output:
    >
    > reallyNotThere: ""
    > reallyNotThere2: ""
    >
    > Not there "undefined"
    > it is not there!
    > Not there 2 "undefined"
    > it is there
    >
    >
    >
    > If
    > (typeof(reallyNotThere) == "undefined")
    > is true, so should
    > (typeof(reallyNotThere2) == "undefined")
    >
    > Rob
    > :)
    W d'Anjos Guest

  4. #3

    Default Re: Bug in IIS 5.1 JScript - undefined strings from Request object

    Hi Wagner,
    > I think the difference is that Session("reallyNotThere") returns null
    > and Request("reallyNotThere2") returns an empty string.
    >
    > Try Response.Write(typeof(reallyNotThere) + " - " +
    > typeof(reallyNotThere2)), if I am correct it should display "undefined
    > - object".
    Not quite - reallyNotThere2 is an object (with no toString method!) that
    becomes the String "undefined" when you put in a String.

    It seems an impossible test - it doesn't report itself as being null or
    undefined plus it's not an empty String.. meaning there is no easy way to
    tell whether it is "undefined" because it's not defined or "undefined"
    because the user typed that... except if you test for this:
    if ("toString" in reallyNotThere2)

    I tried this:

    var reallyNotThere = Session("reallyNotThere") ;
    var reallyNotThere2 = Request("reallyNotThere") ;

    Response.Write("=========<br>"),
    Response.Write("reallyNotThere== null - " + (reallyNotThere == null ) +
    "<br>");
    Response.Write("reallyNotThere === null - " + (reallyNotThere === null ) +
    "<br>");
    Response.Write("reallyNotThere2 == \"\" - " + (reallyNotThere2 == "" ) +
    "<br>");
    Response.Write("reallyNotThere2 === \"\" - " + (reallyNotThere2 === "" ) +
    "<br>");
    Response.Write("reallyNotThere2 == null - " + (reallyNotThere2 == null ) +
    "<br>");
    Response.Write("reallyNotThere2 === null - " + (reallyNotThere2 === null )
    + "<br>");
    Response.Write(typeof(reallyNotThere) + " - " + typeof(reallyNotThere2)+
    "<br>"),
    Response.Write("reallyNotThere is \"" + reallyNotThere + "\" - " +
    "reallyNotThere2 is \"" + reallyNotThere2 + "\"<br>");
    if ("toString" in reallyNotThere2) {
    Response.Write("reallyNotThere2 has a toString<br>");
    } else {
    Response.Write("reallyNotThere2 has no toString<br>");
    }
    Response.Write("=========<br>");




    Output:
    =========
    reallyNotThere== null - true
    reallyNotThere === null - false
    reallyNotThere2 == "" - false
    reallyNotThere2 === "" - false
    reallyNotThere2 == null - false
    reallyNotThere2 === null - false
    undefined - object
    reallyNotThere is "undefined" - reallyNotThere2 is "undefined"
    reallyNotThere2 has no toString
    =========

    Rob
    :)


    Robert Mark Bram Guest

  5. #4

    Default Re: Bug in IIS 5.1 JScript - undefined strings from Request object

    On Sat, 18 Oct 2003 07:45:05 +1000, "Robert Mark Bram"
    <relaxedrob@removethis.optushome.com.au> wrote:
    >Hi Wagner,
    >
    >> I think the difference is that Session("reallyNotThere") returns null
    >> and Request("reallyNotThere2") returns an empty string.
    >>
    >> Try Response.Write(typeof(reallyNotThere) + " - " +
    >> typeof(reallyNotThere2)), if I am correct it should display "undefined
    >> - object".
    >
    >Not quite - reallyNotThere2 is an object (with no toString method!) that
    >becomes the String "undefined" when you put in a String.
    >
    >It seems an impossible test - it doesn't report itself as being null or
    >undefined plus it's not an empty String.. meaning there is no easy way to
    >tell whether it is "undefined" because it's not defined or "undefined"
    >because the user typed that... except if you test for this:
    >if ("toString" in reallyNotThere2)
    >
    >I tried this:
    >
    > var reallyNotThere = Session("reallyNotThere") ;
    > var reallyNotThere2 = Request("reallyNotThere") ;
    I usually do this:
    var reallyNotThere2 = String(Request("reallyNotThere"));
    if (reallyNotThere2 == "" || reallyNotThere2 == "undefined")
    reallyNotThere2 = null;
    and then test for null where appropriate.

    Regards,
    Steve
    Steve van Dongen Guest

  6. #5

    Default Re: Bug in IIS 5.1 JScript - undefined strings from Request object

    Hi Steve!
    > I usually do this:
    > var reallyNotThere2 = String(Request("reallyNotThere"));
    > if (reallyNotThere2 == "" || reallyNotThere2 == "undefined")
    > reallyNotThere2 = null;
    > and then test for null where appropriate.
    I don't like to use this because of the (admittedly remote) possibility that
    I have a text field where "undefined" is a possible value... but I see your
    point.

    Rob
    :)


    Robert Mark Bram Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139