Results 1 to 2 of 2

Thread: scripting ??

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Chennai, India
    Posts
    17

    Exclamation

    hi

    can u explain in detail the difference between Client Scripting and Server side scripting with examples ???

    thanks in advance

    sanju

  2. #2
    Guest

    Talking Ready for an essay?

    OK...

    Client side scripting is Javascript or VB Script. It is processed by your web browser (IE or Netscape) after the page has been downloaded and is most commonly used for animation, presenting basic data gathered from the browser on the page (e.g. time, date etc), dodgy quizes...you know, when you go to a site and you get a message box asking you your name then your age and then it says something sad like "Hello 19 year old Matthew!".

    It's also used alot on warez sites for doing those annoying popup windows (not to mention the annoyingness that Geocities used to bistowe upon us!!) Some site also use it for form validation before the information is sent back to the web server...oh, and ad banners sometimes use it too. It normally goes between <script></script> tags.

    Example:
    Code:
    <SCRIPT LANGUAGE="JAVASCRIPT">
    <!-- hide from older browsers
    now = new Date();
    my_random = now.getTime();
    document.write('<a href="http://ad.doubleclick.net/jump/vpn000177.about.com/compute;svc=;site=visualbasic;chan=compute;syn=vpn000177;pos=slot1;sz=468x60;ord=' + my_random + '">');
    document.write('<img width="468" height="60" border="1" src="http://ad.doubleclick.net/ad/vpn000177.about.com/compute;svc=;site=visualbasic;chan=compute;syn=vpn000177;pos=slot1;sz=468x60;ord=' + my_random + '"></a>');
    // -->
    </SCRIPT>
    I just nicked that code off the top of this VB-World page...it's got something to do with that advert banner at the top. Can't say I gave it much interest though.

    Server side scripting comes in any number of forms (since only the webserver needs to understand it - not your browser) from Perl and PHP to ASP (VB Script) and JSP (Javascript). Server side scipting is processed by the web server BEFORE the page is sent to the web browser. Once you have received the page you normally can no longer see the server script - it is replaced by the outcome of that script.

    In the case of ASP the script falls between <% and %> tags (PHP uses <? ?>)...

    Server side script has many varied uses from database access (this is its most common use) to creating pages that are friendly to ALL browsers (the script can identify the browser and send only the html code that that browser supports). Often there will be a form on a web page that is submitted to a server side script page. The script will gather all the information off the page, check for omissions and then either log it to a database, retrieve info off a database, send out some emails, compile graphics...whatever and then send some kind of page back to the browser.

    ASP Example:
    Code:
    <%@ Language=VBScript %>
    <%
    dim sDBPath
    dim oConn
    dim oRSGuestbook
    
    sDBPath = Server.MapPath("guestbook.mdb")
    set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & sDBPath
    
    set oRSGuestbook = Server.CreateObject("ADODB.Recordset")
    oRSGuestbook.Open "SELECT * FROM Guestbook WHERE Display = True ORDER BY Date, Time, Name", oConn
    %>
    <html>
      <head>
        <title>Matthew's Guestbook</title>
      </head>
      <body bgcolor="#FFFFFF" text="#734D22" link="#C6B6A4" vlink="#734D22" alink="#808000">
      <FONT SIZE="2" FACE="arial, helvetica" face="arial, helvetica" size="3">
      <h3>Here's my guestbook!</h3>
      <p>Have a read...and perhaps even think about <i><b><a href="sign.asp">sign</a></i></b>ing it!?</p>
      <%
      if not oRSGuestbook.BOF and not oRSGuestbook.EOF then
        oRSGuestbook.MoveFirst
        do until oRSGuestbook.EOF
      %>
          <p><table border="1" width="100%" cellspacing="0" cellpadding="10">
            <tr>
              <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td width="20%" rowspan="2" valign="top">
                <p align="center"><img border="0" src="<%=oRSGuestbook("Photo")%>" width="100%"></td>
                <td width="2%" rowspan="2" valign="top"></td>
                <td width="78%" valign="top">
          <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td><FONT SIZE="2" FACE="arial, helvetica" face="arial, helvetica">
              <%if oRSGuestbook("Email") <> "" then%>
              <a href="mailto:<%=oRSGuestbook("Email")%>">
              <%end if%>
              <%=oRSGuestbook("Name")%>
              <%if oRSGuestbook("Email") <> "" then%>
              </a>
              <%end if%>
              <%if (lcase(Request("showip")) = "yes" or lcase(Request("showip")) = "true" or Request("showip") = "1") and (oRSGuestbook("IP") <> "") then response.write " (" & oRSGuestbook("IP") & ")"%>
              </font></td>
              <td width="2%"></td>
              <td>
                <p align="left"><FONT SIZE="2" FACE="arial, helvetica" face="arial, helvetica"><%=oRSGuestbook("Time")%></font></td>
            </tr>
            <tr>
              <td>
              <%if oRSGuestbook("WebSite") <> "" then%>
              <FONT SIZE="2" FACE="arial, helvetica" face="arial, helvetica"><a href="<%=oRSGuestbook("WebSite")%>"><%=oRSGuestbook("WebSite")%></a></font></td>
              <%end if%>
              <td width="2%"></td>
              <td>
                <p align="left"><FONT SIZE="2" FACE="arial, helvetica" face="arial, helvetica"><%=oRSGuestbook("Date")%></font></td>
            </ tr>
            <tr>
              <td colspan="3"> </td>
            </tr>
          </table></td>
            </tr>
            <tr>
              <td width="78%" valign="top"><FONT SIZE="2" FACE="arial, helvetica" face="arial, helvetica"><%=oRSGuestbook("Comment")%></font></td>
            </tr>
          </table></td>
            </tr>
          </table></p>
      <%
        oRSGuestbook.MoveNext
      loop
      end if
      %>
        <a name="lastentry"></a>
        </font>  
      </body>
    </html>
    <%
    oRSGuestbook.Close
    oConn.Close
    set oRSGuestbook = Nothing
    set oConn = Nothing
    %>
    That piece of code gets all the entries from a table in a database and presents the browser with a guestbook. (No sneaky ripping off my code, mind!! )

Posting Permissions

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



Click Here to Expand Forum to Full Width