CSP,即Cache Sever Page,与Java的JSP、.net的ASP高度雷同。都是HTML与服务端代码的混编,实现前后台的交互。
编写BS代码都要使用CSP,但用到的特性很少
##($ZDATETIME($H,3))##
还有其他方式,这里几兴两个例子,实现上基本不用到
#(result.Get("BookTitle"))#
value为 ,则浏览器端代码为:
Link
x 为100%,则浏览器端代码为:
Link
%request.Data可以获取表单的参数,也可以获取URL传入的参数
自动生成医嘱规则
// 省略其他代码...
dhan.csr
获取Session信息
%session.Data("value")
获取URL传值
// /csp/user/MyPage.csp?A=10&a=20&B=30&B=40
Write %request.Data("A",1) // this should be 10
Write %request.Data("a",1) // this should be 20
Write %request.Data("B",1) // this should be 30
Write %request.Data("B",2) // this should be 40
Set %response.ServerSideRedirect = "C:\CacheSys\csp\samples\redirect.csp"
%SYSTEM.Process
获取客户端IP地址:
##class(%SYSTEM.Process).ClientIPAddress($j)
| 方法名 | 说明 |
|---|---|
| ClientIPAddress | 获取客户端IP地址 |
| ClientNodeName | 获取客户端主机名称 |
获取服务端IP:
%request.CgiEnvs("SERVER_NAME")
%request.CgiEnvs("SERVER_ADDR")
其他:
| 方法名 | 说明 |
|---|---|
| Environment | Variable Value |
| AUTH_PASSWORD | Value entered in the client’s authentication dialog. This variable is available only if Basic authentication is used. |
| AUTH_TYPE | Contains the authentication method that the server uses to validate users when they attempt to access a protected script. |
| CONTENT_TYPE | For requests which have attached information, such as HTTP POST and PUT, this is the content type of the data. |
| GATEWAY_INTERFACE | Revision of the CGI specification to which this server complies. Format: CGI/revision |
| HTTP_ACCEPT | Value of the Accept request header that contains a list of accepted formats (MIME types). For example: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel. The values of the fields for the HTTP_ACCEPT variable are concatenated, and separated by a comma (,). |
| HTTP_ACCEPT_CHARSET | Comma-delimited list of the character encodings that the client accepts. |
| HTTP_ACCEPT_LANGUAGE | Contains a string describing the language to use for displaying content (such as en-us). |
| HTTP_AUTHORIZATION | Contains the Base-64 encoded username, password, scheme and realm sent by the client. |
| HTTP_COOKIE | Holds the contents of the client’s cookie(s). |
| HTTP_REFERER | Holds a string that contains the URL of the page that referred the request to the current page using an HTML tag. Note that the URL is the one that the user typed into the browser address bar, which may not include the name of a default document. If the page is redirected, HTTP_REFERER is empty. |
| HTTP_SOAPACTION | SOAPAction HTTP request header field can be used to indicate the intent of the SOAP HTTP request. The value is a URI identifying the intent. SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. An HTTP client MUST use this header field when issuing a SOAP HTTP Request. |
| HTTP_USER_AGENT | Browser the client is using to send the request. General format: software/version library/version. |
| HTTPS | Set to either On or Off (using word, not numerical value). Set to on if the script is being called through a secure server (that is, using SSL/TLS). |
| PATH_TRANSLATED | Translated version of PATH_INFO, in which any virtual-to-physical mapping is applied to the path. |
| REMOTE_ADDR | 客户端IP地址 |
| REMOTE_HOST | Hostname making the request. If the server does not have this information, it should set REMOTE_ADDR and leave this parameter unset. |
| REMOTE_IDENT | If the HTTP server supports RFC 931 identification, then this variable is set to the remote username retrieved from the server. |
| REMOTE_USER | Name of the user as it is derived from the authorization header sent by the client |
| REQUEST_METHOD | HTTP 方法, GET, HEAD, POST,等. |
| SERVER_NAME | 服务器名称,或DNS别名,IP地址 |
| SERVER_PORT | 服务器端口,如: 80 |
| SERVER_PORT_SECURE | Set to either 0 or 1. If the request is being handled on the web server’s secure port, then it is set to 1. Otherwise, it is set to 0. |
| SERVER_PROTOCOL | Name and revision of the information protocol that the request came in with. Format: protocol/revision |
| SERVER_SOFTWARE | Web server 名称和软件版本 格式: 名称/版本 |