Object required?

Discussion in 'Javascript' started by groupie, Feb 2, 2008.

  1. groupie

    groupie Guest

    I get the following error on an ASP page but I don't understand why :
    line 13 is if ( writeSessionCookie ('pans','drizzle'))

    The error:
    Error Type:
    Microsoft JScript runtime (0x800A138F)
    Object expected
    /lands/testpage.asp, line 13

    The code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <script language="JavaScript" type="text/javascript" src = "scripts/
    cookies.js"></script>
    <head>
    <title>page for testing stuff</title>
    </head>

    <body>
    <script language="JavaScript" type="text/javascript">
    <%
    if ( writeSessionCookie ('pans','drizzle'))
    document.write("cookie written");
    else
    document.write("cookie not written");
    %>
    </script>
    </body>
    </html>

    The function:
    function writeSessionCookie (cookieName, cookieValue) {

    if (testSessionCookie()) {
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) +
    "; path=/";
    return true;
    }
    else
    return false;
    }
    groupie, Feb 2, 2008
    #1
    1. Advertising

  2. groupie wrote:
    > I get the following error on an ASP page but I don't understand why :
    > line 13 is if ( writeSessionCookie ('pans','drizzle'))
    >
    > The error:
    > Error Type:
    > Microsoft JScript runtime (0x800A138F)
    > Object expected
    > /lands/testpage.asp, line 13
    >
    > The code:
    > <html xmlns="http://www.w3.org/1999/xhtml">
    > <script language="JavaScript" type="text/javascript" src = "scripts/
    > cookies.js"></script>


    You were recommended to remove the `language' attribute, were you not?

    > <head>
    > <title>page for testing stuff</title>
    > </head>
    >
    > <body>
    > <script language="JavaScript" type="text/javascript">


    Same here.

    > <%
    > if ( writeSessionCookie ('pans','drizzle'))
    > document.write("cookie written");
    > else
    > document.write("cookie not written");
    > %>
    > </script>
    > </body>
    > </html>
    >
    > The function:
    > function writeSessionCookie (cookieName, cookieValue) {
    >
    > if (testSessionCookie()) {
    > document.cookie = escape(cookieName) + "=" + escape(cookieValue) +
    > "; path=/";
    > return true;
    > }
    > else
    > return false;
    > }


    writeSessionCookie() contained in scripts/cookies.js included via the
    `script' element is declared *client-side* as document.write() works only
    client-side. Everything inside <% ... %> is executed *server-side*. IOW,
    neither method is just not there when you call it. Hence the error message.

    This is the second time you demonstrate a complete lack of understanding for
    client-side and server-side scripting. You should finally learn the basics
    and the basic difference between the two before you continue this
    half-knowledged messing around.


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
    Thomas 'PointedEars' Lahn, Feb 2, 2008
    #2
    1. Advertising

  3. groupie

    groupie Guest

    On Feb 2, 10:11 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > groupie wrote:
    > > I get the following error on an ASP page but I don't understand why :
    > > line 13 is if ( writeSessionCookie ('pans','drizzle'))

    >
    > > The error:
    > > Error Type:
    > > Microsoft JScript runtime (0x800A138F)
    > > Object expected
    > > /lands/testpage.asp, line 13

    >
    > > The code:
    > > <html xmlns="http://www.w3.org/1999/xhtml">
    > > <script language="JavaScript" type="text/javascript" src = "scripts/
    > > cookies.js"></script>

    >
    > You were recommended to remove the `language' attribute, were you not?
    >
    > > <head>
    > > <title>page for testing stuff</title>
    > > </head>

    >
    > > <body>
    > > <script language="JavaScript" type="text/javascript">

    >
    > Same here.
    >
    >
    >
    >
    >
    > > <%
    > > if ( writeSessionCookie ('pans','drizzle'))
    > >    document.write("cookie written");
    > > else
    > >    document.write("cookie not written");
    > > %>
    > > </script>
    > > </body>
    > > </html>

    >
    > > The function:
    > > function writeSessionCookie (cookieName, cookieValue) {

    >
    > > if (testSessionCookie()) {
    > >     document.cookie = escape(cookieName) + "=" + escape(cookieValue) +
    > > "; path=/";
    > >     return true;
    > >   }
    > >   else
    > >    return false;
    > > }

    >
    > writeSessionCookie() contained in scripts/cookies.js included via the
    > `script' element is declared *client-side* as document.write() works only
    > client-side.  Everything inside <% ... %> is executed *server-side*.  IOW,
    > neither method is just not there when you call it.  Hence the error message.
    >
    > This is the second time you demonstrate a complete lack of understanding for
    > client-side and server-side scripting.  You should finally learn the basics
    > and the basic difference between the two before you continue this
    > half-knowledged messing around.
    >
    > PointedEars
    > --
    > var bugRiddenCrashPronePieceOfJunk = (
    >     navigator.userAgent.indexOf('MSIE 5') != -1
    >     && navigator.userAgent.indexOf('Mac') != -1
    > )  // Plone, register_function.js:16- Hide quoted text -
    >
    > - Show quoted text -


    Slowly learning...
    So I know now that ASP renders the page BEFORE Javascript.
    In that case in the sample below, is it possible to use session cookie
    values (read on client side) (email and pword) to select from a table
    (server side sql) (the example uses Request() set in previous page:
    looking to replace them with the variables).

    <script type="text/javascript">
    var email = getCookieValue('email'); //already set in previous page
    var pword = getCookieValue('pword'); //already set in previous page
    </script>

    <%
    var strSql;
    if ((Request("email") != "") && (Request("pword") != "")) {
    strSql = "SELECT email, pword FROM logintable where email = '" +
    Request("email") +
    "' and pword = '" + Request("pword") + "';";

    // more code....
    %>
    groupie, Feb 2, 2008
    #3
  4. groupie

    Stevo Guest

    Thomas 'PointedEars' Lahn wrote:
    > groupie wrote:
    >> <script language="JavaScript" type="text/javascript" src = "scripts/

    > You were recommended to remove the `language' attribute, were you not?


    Yeah groupie, you should be aware that language="javascript" is the
    cause of more problems in javascript than anything else. Almost every
    problem I've ever seen resolved was fixed by this being removed. We
    should add this as item #1 in the FAQ:

    Problem: Anything, Solution: Remove language="javascript" from script.

    It's such an annoyance that Safari 3.0, Firefox 3.0 and IE8 have all
    decided to throw an exception for any script tag that has
    language="javascript" in it. </sarcasm>
    Stevo, Feb 2, 2008
    #4
  5. groupie wrote:
    > [...] Thomas 'PointedEars' Lahn [...] wrote:
    >> writeSessionCookie() contained in scripts/cookies.js included via the
    >> `script' element is declared *client-side* as document.write() works only
    >> client-side. Everything inside <% ... %> is executed *server-side*. IOW,
    >> neither method is just not there when you call it. Hence the error message.
    >>
    >> This is the second time you demonstrate a complete lack of understanding for
    >> client-side and server-side scripting. You should finally learn the basics
    >> and the basic difference between the two before you continue this
    >> half-knowledged messing around.
    >> [...]

    >
    > Slowly learning...


    Yes, indeed. I ask you *again* to trim your quotes.

    > So I know now that ASP renders the page BEFORE Javascript.


    Not quite. "ASP" "renders" the "page", including the execution of
    the server-side script, before the client-side script is executed.

    > In that case in the sample below, is it possible to use session cookie
    > values (read on client side) (email and pword) to select from a table
    > (server side sql) (the example uses Request() set in previous page:
    > looking to replace them with the variables).


    ISTM you are trying password auto-fill, so it should be the other way
    around. First the client makes the request, sending the Cookie header along
    with it (a previous Set-Cookie or Set-Cookie2 header, or document.cookie
    assignment would have set the cookie). You should then evaluate the header
    value in order to generate the proper response body via ASP.

    Be advised, though, that storing passwords as-is in session cookies is a bad
    idea. Many user agents have built-in features to facilitate password form
    auto-fill in which case the password is stored in the user profile using a
    strong encoding instead.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
    Thomas 'PointedEars' Lahn, Feb 2, 2008
    #5
  6. groupie

    groupie Guest

    On Feb 2, 10:45 pm, Stevo <> wrote:
    > Thomas 'PointedEars' Lahn wrote:
    > > groupie wrote:
    > >> <script language="JavaScript" type="text/javascript" src = "scripts/

    > > You were recommended to remove the `language' attribute, were you not?

    >
    > Yeah groupie, you should be aware that language="javascript" is the
    > cause of more problems in javascript than anything else. Almost every
    > problem I've ever seen resolved was fixed by this being removed. We
    > should add this as item #1 in the FAQ:
    >
    > Problem: Anything, Solution: Remove language="javascript" from script.
    >
    > It's such an annoyance that Safari 3.0, Firefox 3.0 and IE8 have all
    > decided to throw an exception for any script tag that has
    > language="javascript" in it. </sarcasm>


    Stevo, you muppet, learn to read the flow of group discussions as soon
    as you take your head out of your ass. That post was from PointedEars.
    groupie, Feb 3, 2008
    #6
  7. groupie

    groupie Guest

    > You should then evaluate the header
    > value in order to generate the proper response body via ASP.


    I'm not sure what you mean : I'm reading the values back to use in an
    SQL statement (I accept the security implications for now). It's the
    syntax of the IF and SQL statements I'm trying to code.

    <script type="text/javascript">
    var email = getCookieValue('email'); //already set in previous page
    var pword = getCookieValue('pword'); //already set in previous page
    </script>

    <%
    var strSql;
    //if ((Request("email") != "") && (Request("pword") != "")) {
    if ((%>email<% != "") && (%>pword<% != "")) {
    strSql = "SELECT email, pword FROM logintable where email = '"
    + email +
    "' and pword = '" + pword + "';";

    // more code....
    %>
    groupie, Feb 3, 2008
    #7
  8. groupie wrote:
    > On Feb 2, 10:45 pm, Stevo <> wrote:
    >> Thomas 'PointedEars' Lahn wrote:
    >>> groupie wrote:
    >>>> <script language="JavaScript" type="text/javascript" src = "scripts/
    >>> You were recommended to remove the `language' attribute, were you not?

    >> Yeah groupie, you should be aware that language="javascript" is the
    >> cause of more problems in javascript than anything else. Almost every
    >> problem I've ever seen resolved was fixed by this being removed. We
    >> should add this as item #1 in the FAQ:
    >>
    >> Problem: Anything, Solution: Remove language="javascript" from script.
    >>
    >> It's such an annoyance that Safari 3.0, Firefox 3.0 and IE8 have all
    >> decided to throw an exception for any script tag that has
    >> language="javascript" in it. </sarcasm>

    >
    > Stevo, you muppet, learn to read the flow of group discussions as soon
    > as you take your head out of your ass. That post was from PointedEars.


    This was uncalled for. Stevo's sarcastic comment, however inappropriate in
    content, was to my *aside* recommending to remove the `language' attribute,
    and so in that sense was appropriate to be posted as a followup like he did.

    While that particular recommendation is unlikely to solve your problem, it
    was and is good advice nonetheless. Not following it may cause a poster to
    be perceived as not being able/willing to follow given advice at all, and so
    further dealing with their postings may be deemed a waste of time. Use of
    street language as displayed here could then only confirm the correctness of
    such an assessment.


    Score adjusted

    PointedEars
    Thomas 'PointedEars' Lahn, Feb 3, 2008
    #8
  9. groupie

    VK Guest

    On Feb 3, 4:52 pm, groupie <> wrote:
    > > You should then evaluate the header
    > > value in order to generate the proper response body via ASP.

    >
    > I'm not sure what you mean


    He means that server-side processing instructions and client-side
    Javascript statements are two completely different unrelated things.
    From previous similar threads I know that this rather simple concept
    is extremely hard to comprehend to many PHP and ASP developers: so I
    will try to give some more explanations.

    Server-side processing instructions - in your case all those <%...%>
    thingies - being processed, as their name suggests, on the server
    while preparing the page content to be sent to client. At this stage
    client-side Javascript doesn't exist yet, because the page is not
    parsed yet by browser.
    After all server-side processing instructions being accomplished, the
    final page content being sent to client. If the page contains
    Javascript in it, if Javascript supported by browser, and if this
    support is not turned off by user: then browser creates Global context
    for your script and trying to execute it. On this stage server-side
    processor doesn't exist anymore for Javascript - it is left long time
    ago on the server.

    P.S. I once was thinking of this puzzling catcha, because I met
    several experienced and certified PHP/ASP coders but I had to explain
    them this server-side vs. client-side concept nearly on fingers and
    color cubes and balls before we could come to any result :)
    I guess the main gotcha is that in the source both kind of
    instructions are oftenly staying together, so forcing into a fake
    assumption "close on the screen - close in the life". Some may have a
    better idea.



    : I'm reading the values back to use in an
    > SQL statement (I accept the security implications for now). It's the
    > syntax of the IF and SQL statements I'm trying to code.
    >
    > <script type="text/javascript">
    > var email = getCookieValue('email'); //already set in previous page
    > var pword = getCookieValue('pword'); //already set in previous page
    > </script>
    >
    > <%
    > var strSql;
    > //if ((Request("email") != "") && (Request("pword") != "")) {
    > if ((%>email<% != "") && (%>pword<% != "")) {
    > strSql = "SELECT email, pword FROM logintable where email = '"
    > + email +
    > "' and pword = '" + pword + "';";
    >
    > // more code....
    > %>
    VK, Feb 3, 2008
    #9
  10. groupie

    Stevo Guest

    groupie wrote:
    > On Feb 2, 10:45 pm, Stevo <> wrote:
    >> Thomas 'PointedEars' Lahn wrote:
    >>> groupie wrote:
    >>>> <script language="JavaScript" type="text/javascript" src = "scripts/
    >>> You were recommended to remove the `language' attribute, were you not?

    >> Yeah groupie, you should be aware that language="javascript" is the
    >> cause of more problems in javascript than anything else. Almost every
    >> problem I've ever seen resolved was fixed by this being removed. We
    >> should add this as item #1 in the FAQ:
    >>
    >> Problem: Anything, Solution: Remove language="javascript" from script.
    >>
    >> It's such an annoyance that Safari 3.0, Firefox 3.0 and IE8 have all
    >> decided to throw an exception for any script tag that has
    >> language="javascript" in it. </sarcasm>

    >
    > Stevo, you muppet, learn to read the flow of group discussions as soon
    > as you take your head out of your ass. That post was from PointedEars.


    Groupie, you teletubby, you need to learn to recognize sarcasm :)

    As Thomas said in his response, I was taking a sarcastic dig at him
    telling you something that wasn't relevant. So I played the fake
    agreeing with him stance. There should be a sarcastic font we can use in
    these groups :)
    Stevo, Feb 3, 2008
    #10
  11. groupie

    groupie Guest

    On Feb 3, 2:35 pm, VK <> wrote:
    > I guess the main gotcha is that in the source both kind of
    > instructions are oftenly staying together, so forcing into a fake
    > assumption "close on the screen - close in the life". Some may have a
    > better idea.


    Ah Ok I see. Perhaps your reply could be put into the FAQ? It was very
    succint.

    If I understand what you're saying then, the (server-side) SQL
    statement in the <% %> 'tags' below won't contain the values from the
    variables, because the (client-side) <script></script> values haven't
    been retrieved yet?

    <script type="text/javascript">
    var email = getCookieValue('email'); //already set in previous page
    var pword = getCookieValue('pword'); //already set in previous page
    </script>

    <%
    var strSql;
    //if ((Request("email") != "") && (Request("pword") != "")) {
    if ((%>email<% != "") && (%>pword<% != "")) {
    strSql = "SELECT email, pword FROM logintable where email = '"
    + email + "' and pword = '" + pword + "';";

    // more code....
    %>

    So is there a way of using values retrieved from a cookie in an SQL
    statement then?

    Stevo: Ok apologies. Flipped for a minute there </apology> :)
    groupie, Feb 3, 2008
    #11
  12. groupie

    VK Guest

    On Feb 3, 7:11 pm, groupie <> wrote:
    > > I guess the main gotcha is that in the source both kind of
    > > instructions are oftenly staying together, so forcing into a fake
    > > assumption "close on the screen - close in the life". Some may have a
    > > better idea.

    >
    > Ah Ok I see. Perhaps your reply could be put into the FAQ?
    > It was very succinct.


    I though once of a FAQ proposal but the thing is that no one is asking
    about it in the way to make some general question. FAQ has "question-
    answer" structure, and what question to use? "What is the difference
    between server-side and client-side processing?" I never saw such
    question on c.l.j. It is always has to be pulled out from OP in order
    to help him/her from a completely different original question.

    > If I understand what you're saying then, the (server-side) SQL
    > statement in the <% %> 'tags' below won't contain the values from the
    > variables, because the (client-side) <script></script> values haven't
    > been retrieved yet?


    Right.

    > So is there a way of using values retrieved from a cookie in an SQL
    > statement then?


    Setting and reading cookie is not an exclusive privilege of
    Javascript. Any server can do it (if accepted by client). If there are
    cookies for given domain, they are being sent as part of request
    header from client to server: no custom Javascript needed, it is done
    by browser itself. So in your ASP block server-side you may check for
    the presence of cookie and use them in any way you need them. If
    cookies are not set yet, you can prepare and set them via the response
    header from your server.
    VK, Feb 3, 2008
    #12
  13. groupie

    groupie Guest

    On Feb 3, 4:36 pm, VK <> wrote:
    > Setting and reading cookie is not an exclusive privilege of
    > Javascript. Any server can do it (if accepted by client). If there are
    > cookies for given domain, they are being sent as part of request
    > header from client to server: no custom Javascript needed, it is done
    > by browser itself. So in your ASP block server-side you may check for
    > the presence of cookie and use them in any way you need them. If
    > cookies are not set yet, you can prepare and set them via the response
    > header from your server.


    Sorry I don't understand. How would I have to change the code posted
    to use the cookie values? I've used Request("email") in the SQL which
    works (the value is passed from previously SUBMITed page), however I
    would like to know how to use the value from the cookie, that was set
    in the previous page.

    The cookie value is retrieved with the custom javascript function
    getCookieValue() which has been included using <script type="text/
    javascript" src = "scripts/cookies.js"></script>. Somewhere I need to
    call this function, to get the cookie value, to pass into the SQL
    statement.

    I'm really beginning to hate javascript :-(
    groupie, Feb 3, 2008
    #13
  14. groupie

    VK Guest

    On Feb 3, 7:56 pm, groupie <> wrote:
    > On Feb 3, 4:36 pm, VK <> wrote:
    >
    > > Setting and reading cookie is not an exclusive privilege of
    > > Javascript. Any server can do it (if accepted by client). If there are
    > > cookies for given domain, they are being sent as part of request
    > > header from client to server: no custom Javascript needed, it is done
    > > by browser itself. So in your ASP block server-side you may check for
    > > the presence of cookie and use them in any way you need them. If
    > > cookies are not set yet, you can prepare and set them via the response
    > > header from your server.

    >
    > Sorry I don't understand. How would I have to change the code posted
    > to use the cookie values? I've used Request("email") in the SQL which
    > works (the value is passed from previously SUBMITed page), however I
    > would like to know how to use the value from the cookie, that was set
    > in the previous page.
    >
    > The cookie value is retrieved with the custom javascript function
    > getCookieValue() which has been included using <script type="text/
    > javascript" src = "scripts/cookies.js"></script>. Somewhere I need to
    > call this function, to get the cookie value, to pass into the SQL
    > statement.


    SQL statement is being executed server-side. At the moment of
    executing server-side statements your program already has access to
    cookie (if set). If not it can set them by issuing necessary headers
    in the response. In ASP it is all handled by Request.Cookies and
    Response.Cookies respectively. Client-side scripting is not needed. A
    beginners-friendly explanation and samples can be found at
    http://www.w3schools.com/asp/asp_cookies.asp

    > I'm really beginning to hate javascript :-(

    For what? For not being able to be executed client-side before
    actually being served to client? With the same reason you may hate
    your browser then for not being able to display a page before you
    actually came to the necessary URL.
    VK, Feb 3, 2008
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bucko
    Replies:
    1
    Views:
    328
    Alvin Bruney
    Oct 25, 2003
  2. rob

    Recordset - Object Required

    rob, Jun 7, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    2,238
    Trevor Benedict R
    Jun 15, 2004
  3. Just D.
    Replies:
    0
    Views:
    436
    Just D.
    Mar 10, 2006
  4. Carolyn Speakman
    Replies:
    1
    Views:
    1,037
    Keith M. Corbett
    Jul 30, 2004
  5. Eric
    Replies:
    0
    Views:
    592
Loading...

Share This Page