129e2051e253f6ddfa74d44d0fadc48e.ppt
- Количество слайдов: 59
Active Server Page - ASP in Java. Script 王金龍、陳彥錚 銘傳大學 資管系
Content u Introduction u Object Models u Request Object u Response Object u Server Object u Application and Session Objects u Installable Components for ASP
Introduction u Microsoft’s newest server-based technology for building dynamic interactive web pages u No compiler u Text editor u Browser independent u Object-oriented u Compatible to any Active. X scripting u Transparent to users
ASP Usage <%@language=JScript%>
Complete ASP Program <%@Language=JScript %>
… <% … ASP script which runs on the server … %>Server-side includes u u Include text files in pages u Virtual file addresses u u Physical u u
" src="https://present5.com/presentation/129e2051e253f6ddfa74d44d0fadc48e/image-7.jpg" alt=" Top
Next
Previous
…
Basic Statements u <% Response. Write(“string”) %> u Output u <% a string ( more readable ) = “string” %> or <%=Var. Expression%> u Insert a string u <%=Request. Form(“user. Name”)%> u <% Response. Redirect(“URL”) %> u Redirect to the URL u <% // Some Comments %>
An ASP Example <%@language=JScript%> <% num=Request. Form("num. Of. Hr"); msg="Welcome to My ASP Example!"; %>
<% for ( i=1; i<=num; i++) { %> Iteration <%=i%> <% Response. Write("
"); } %>
Please input" src="https://present5.com/presentation/129e2051e253f6ddfa74d44d0fadc48e/image-10.jpg" alt="asp. Example 1. html
Source File in Web Client
Iteration
Iteration
Iteration
Iteration
Iteration
1 2 3 4 5
Built-In ASP Objects u Request Object u To retrieve the values that the client browser passed to the server during an HTTP request. u Response u To Object send output to the client. u Server u Provide utility functions on the server.
Built-In ASP Objects (cont. ) u Application u To share information among all users of a given application. (Like global variables) u Session u To store information needed for a particular user-session. (Like local variables) u Object. Context u To commit or abort a transaction, managed by Microsoft Transaction Server (MTS).
Client Request Object Collection: Form Query. String Server. Variables Cookie Client. Certificate Response Object Collection: Cookie (Properties) (methods) Server Object (method) Application Object Session Object (properties) (methods)
Request Object u Provide all the information about the user’s request to applications u Collection u. A data store that can store values by linking each one to a unique key
Collections in Request Object u Five collections u Query. String: HTTP query string (GET) Query. String u Form: Form elements (POST) Form u Server. Variables: HTTP and environment Server. Variables variables u Cookie: Cookie sent from the browser Cookie u Client. Certificate: Certificate values (SSL: https) Client. Certificate u Usage variable = Request. collection. Name(“key”)
Properties and Methods u Properties u Total. Bytes: Read-only. Specifies the total number of bytes the client is sending in the body of the request. u Methods u Binary. Read(count): Retrieves data sent to the server from the client as part of a POST request.
Query. String Collection: Get u The names and values of form are put into a query string u The amount of data can be sent is limited to around 1000 characters u Usage u variable = Request. Query. String(“name”)
query. Test. asp? name=Mickey+Mouse&age=50 <%@language=JScript%>
name = <%= Request. Query. String("name") %>
pub = <% = Request. Query. String("pub") %>
Form Collection: Post u The name and values of the form are encoded into the request header u Usage u variable = Request. Form(“name”)
text" src="https://present5.com/presentation/129e2051e253f6ddfa74d44d0fadc48e/image-23.jpg" alt="form. Test. html