form QueryString  ServerVariables
Cookies ClientCertificate  

Request Object is one of

the central objects in the ASP object model.When a webbrowser or other client

applications ask for a page from webserver we can say that client is making

a request.When a client supply a specific URL Request object is responsible

for packing  all this information and making it easily accessible to the

ASP application.The information is categorized into five sets of information.Since

each set of information can include multiple individual piece of information

, data is stored as collection.In a collection , each piece of information is

stored as a name/value pair.

The Asp Request object

has five collections.All variables can be accessed directly by calling Request(variable)

without the collection name. In this case, the Web server searches the collections

in the following order.

 

  • QueryString

    The values that are provided in the URL that are sent by the client.In the

    URL  , the client can include name/value pairs of information after file

    name.This information is stored in QueryString collection.

  • Form If

    the client sends a form request , then the values of form elements are stored

    in Form collection.

  • ServerVariables

    The webserver itself has great deal of information about the request.These

    are called           

    HTTP Server Variables

  • Cookies

    If the client is sending any cookie along with request , then they are included

    in this collection.

  • ClientCertificate

    If the client sends any security certificate to the sever , then they are stored

    in this collection.


  • Asp Form Collection

    ASP needs input

    from user inorder to make decision.The simplest technique for this is using

    forms.The form has a button to submit information back to the server.The opening

    of form tag has two attributes Action and Method.

    The Action attribute of <form> tag tells the browser what page

    is going to be opened when the submit button is pressed.The Method attribute

    determines which of the two ways(GET or POST) that the browser will use to send

    the information to the server.The form also provide space called Fields to type

    information.The following is a simple example.

    <Form

    action=”register.asp” method = “Post”>

    Enter your name : <input type = “text” 

    name = “name” >

    Address            

    :<input type = “text”  name = “address” >

    <input type = “submit”  value=”submit”

    ><input type = “Reset”  value=”Reset”>

    </form>

    When

    you fill in the text boxes of form and press submit button all the values are

    stored in Form Collection.Please note that in this case browser is using POST

    method to send the information.All the items in form collection are stored in

    name/value pair.

    Retrieving

    data from Form Collection

    We

    can retrieve data from Form Collection using following syntax:

    Request.

    form(“Field_name”)

    See

    the following example.

    <html>

    <head><title>Formcollection Example</title></head>

    <body>

    <form action=”register.asp” method=”post”>

    <table>

    <tr>

    <td>Enter your name:</td><td><input

    type=”text” name=”name”></td>

    <tr>

    <td>Enter your Password:</td><td><input

    type=”password” name=”pswd”></td>

    <tr>

    <td></td><td><input type=”submit”

    value=”Login”><input type=”reset” value=”Clear”></td>

    </table>

    </form>

    <br><Br><hr>

    <b>

    You Entered the following details</b><Br>

    Name

    = <%=request.form(“name”)%><Br>

    Password = <%=request.form(“pswd”)%><Br>

    </body>

    </html>

    Save

    this code as register.asp in AspEg directory.Then view the results.

    Sometimes

    a form contains two different fields with same field name.In this case the values

    are stored separated by commas.For eg. name= Cindy, John . In this case a keyword

    Count is used to track the number of values in a given name/value pair. For

    Example:

    <%=Request.Form(“name”).count%>

    Will return the number of name/value pairs that have the name ‘name’.

    We can retrieve one of the values using

    the syntax <%=Request.Form(“name”)(index)%>.

    Where index is an integer between 1 to Request.Form(“name”)Count

    .

    Eg:Modify

    register.asp adding following code.

    <html>

    <head><title>Formcollection Example</title></head>

    <body>

    <form action=”register.asp” method=”post”>

    <table>

    <tr>

    <td>Enter your First name:</td><td><input

    type=”text” name=”name”></td>

    <tr>

    <td>Enter your Last name:</td><td><input

    type=”text” name=”name”></td>

    <tr>

    <td>Enter your Password:</td><td><input

    type=”password” name=”pswd”></td>

    <tr>

    <td></td><td><input type=”submit”

    value=”Login”><input type=”reset” value=”Clear”></td>

    </table>

    </form>

    <Br><Br><hr>

    <b>

    You Entered the following details</b><Br>

    Total

    value :<%=request.form%><Br>

    Name = <%=request.form(“name”)%><Br>

    Password = <%=request.form(“pswd”)%><Br>

    Name count = <%=request.form(“name”)Count%><Br>

    <%if request.form(“name”)Count<>0

    then%>

    First name = <%=request.form(“name”)(1)%><Br>

    Last name = <%=request.form(“name”)(2)%>

    <%End if%>

    </body>

    </html>

    Please

    refer itechies.net for more input types in <form>

    The

    following is complete example:

    <html>

    <head><title>Big example</title>

    </head>

    <body>

    <h1>Here is the first form</h1>

    <form action=”formexample.asp” method=”post”>

    <table>

    <tr>

    <td>Your login name</td><td><input

    type=”text” name=”login”></td>

    <tr>

    <td>Your Password</td><td><input

    type=”password” name=”pswd”></td>

    <tr>

    <td>Your Comments</td><td><textarea

    name=”textarea” rows=”3″ cols=”30″></textarea></td>

    <tr>

    <td>do u want to continue</td><td><input

    type=”radio” name=”radio1″ value=”yes”>Yes</td>

    <tr><td></td><td><input type=”radio”

    name=”radio1″ value=”No”>No</td>

    <tr>

    <td>Check which color u like</td><td><input

    type=”checkbox” name=”check1″ value=”Red”>Red</td>

    <tr><td></td><td><input type=”checkbox”

    name=”check1″ value=”Blue”>Blue</td>

    <tr><td></td><td><input type=”checkbox”

    name=”check1″ value=”Green”>Green</td>

    <tr>

    <td>Select the state</td><td><select

    name=”dropdown”>

    <option value=”NY”>NY

    <option value=”NJ”>NJ

    <option value=”NC”>NC

    <option value=”FL”>FL

    </select></td>

    <tr>

    <td>Select the state</td><td><select

    name=”scroll” size=3>

    <option value=”NY”>NY

    <option value=”NJ”>NJ

    <option value=”NC”>NC

    <option value=”FL”>FL

    </select></td>

    <tr>

    <td><input type=”submit” Value=”submit”></td>

    <td><input type=”reset” value=”reset”></td>

    </table>

    </form>

    </body>

    </html>

    Top


    Asp QueryString Collection

    QueryString is

    an extra query information that is passed to the server in the form of name/value

    pair.A queryString is append to the URL with questionmark , ‘?’ .

    Generating

    queryString

    1)By clicking

    on the anchor tag <a> which already has an in-built querystring.

    <a

    href=”login.asp?name=”Cindy”>Login</a>

    2)queryString

    is generated when browser uses GET method to send information to server.

    <Form

    action=”login.asp” method = “Get”>

    Enter your name : <input type = “text” 

    name = “name” >

    Password           

    :<input type = “Password”  name = “password” >

    <input type = “submit”  value=”Submit”

    ><input type = “Reset”  value=”Reset”>

    </form>

    When

    the user enter name(for eg. Cindy) and Password (for eg.password) feilds and

    click on Submit button the following URL is generated.

    http://localhost/AspEg/login.asp?name=Cindy&password=password

    Retrieving

    QueryString

    We

    can retrieve QueryString using following statement:

    <%=Request.Querystring(“Field_name”)%>

    or <%=Request.Querystring%>

    Like

    Form collection in QueryString also count is used to track the the number of

    values in a given name/value pair. For Example:

    <%=Request.QueryString(“name”)Count%>

    Will return the number of name/value pairs that have the name ‘name’.

    We can retrieve one of the values using

    the syntax <%=Request.QueryString(“name”)(index)%>.

    Where index is an integer between 1 to Request.QueryString(“name”)Count

    .

    <html>

    <head><title>Formcollection Example</title></head>

    <body>

    <form action=”login.asp” method=”Get”>

    <table>

    <tr>

    <td>Enter your First name:</td><td><input

    type=”text” name=”name”></td>

    <tr>

    <td>Enter your Last name:</td><td><input

    type=”text” name=”name”></td>

    <tr>

    <td>Enter your Password:</td><td><input

    type=”password” name=”pswd”></td>

    <tr>

    <td></td><td><input type=”submit”

    value=”Login”><input type=”reset” value=”Clear”></td>

    </table>

    </form>

    <Br><Br><hr>

    <b>

    You Entered the following details</b><Br>

    Name = <%=request.querystring(“name”)%><Br>

    Password = <%=request.form(“pswd”)%><Br>

    Name count = <%=request.querystring(“name”)Count%><Br>

    <%if request.querystring(“name”)Count<>0

    then%>

    First name = <%=request.querystring(“name”)(1)%><Br>

    Last name = <%=request.querystring(“name”)(2)%>

    <%End if%>

    </body>

    </html>

    When

    you submit he Login Button The following URL generated.

    http://localhost/AspEg/login.asp?name=Cindy&name=John&password=password

    Top


    Asp ServerVariables Collection

    ServerVariables

    collection holds all HTTP headers and additional items of information about

    the server.These headers include a wide array of information from the type of

    browser being used to name of the page that user refered.To retrieve a value

    in the collection use the following syntax:

    <%=Request.Servervariables(“varName”)%>

    The

    following is the table of servervariable collection.

     

    Variable Name Value
    ALL_HTTP HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,

    image/png, */*

                          

    HTTP_ACCEPT_LANGUAGE:en HTTP_CONNECTION:Keep-Alive HTTP_HOST:localhost

                          

    HTTP_USER_AGENT:Mozilla/4.7 [en] (Win95; I)

                          

    HTTP_COOKIE:ASPSESSIONIDFFFGKKWX=ADMFAELCKAJBLILGLBKHFKPF

                          

    HTTP_ACCEPT_ENCODING:gzip HTTP_ACCEPT_CHARSET:iso-8859-1,*,utf-8 

    ALL_RAW Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,

    image/png, */*

                          

    Accept-Language: en Connection: Keep-Alive Host: localhost User-Agent: Mozilla/4.7

                          

    [en] (Win95; I) Cookie: ASPSESSIONIDFFFGKKWX=ADMFAELCKAJBLILGLBKHFKPF

                          

    Accept-Encoding: gzip Accept-Charset: ISO-8859-1,*,utf-8 

    APPL_MD_PATH /LM/W3SVC/1/ROOT/BegAsp
    APPL_PHYSICAL_PATH C:\Inetpub\wwwroot\BegAsp\

    Top


    asp Cookies Collection

    Cookies are text

    files that resides on user’s computer.They store information about the user

    and are used by a particular server ,that the user has visited previously,to

    personalize web pages.Each webserver ,when a user access to it , can send a

    cookie ,which the user must accept if the server is to utilize the cookie on

    the user’s machine during future visits.A cookie can only store information

    which the user send voluntary and that can only happen if the  ‘accept

    cookie’ option is turned on by the user.

    More details about

    cookies will be discussed in session Cookies

    Top


    Asp ClientCertificate Collection

    Client certificate

    is an encrypted number that is stored in a file on user’s computer.The browse

    send the number along with the request for an ASP page.They allow the server

    to identify the user sothat the server can send sensitive information to a certified

    user via secure transmission methods.

    Inorder to do

    that , a secure socket Later(SSL) protocol must be used.The latest version of

    SSL protocol is SSL3.0/PCTI.SSL/PCT allows three tasks.

  • Server and Client

    Authentication – ie ensure that the data is being send from ‘approved’ client

    to the correct server.

  • Encryption –

    ensures that the data can only be read by the server that is intended for.

  • DataIntegrity – ensures that the data entered arrives unaltered

    , exactly as it was send.

    When the SSL protocol

    is used , URLs are prefixed by https:// instead of http:// .

    We can retrieve the clientcertificate  values by following

    method.

    <%

    for each item in Request.ClientCertificate

      response.write(Item & ” ” &

    request.Clientcertificate(item) & “<Br>”)

    Next

    %>

     

     

    Certificate A string containing binory stream of client certificate

    in ANS.1 format.

    flags Provide additional informations.
    Issuer A String containing the information of issuer of certificate.
    SerialNo Certificate serial no
    Subject a string containing the subject of certificate
    ValidFrom date specify when the certificate becomes valid 
    ValidUntil expiration date of certificate.

    Top


     

    Leave a Comment