• 9. CSP-Cache Server Page


    一、什么是CSP [了解]

    CSP,即Cache Sever Page,与Java的JSP、.net的ASP高度雷同。都是HTML与服务端代码的混编,实现前后台的交互。

    编写BS代码都要使用CSP,但用到的特性很少

    二、 嵌入动态代码(服务端主动)[了解]

    1.单个语句

    ##($ZDATETIME($H,3))##
    
    • 1

    2.循环

    还有其他方式,这里几兴两个例子,实现上基本不用到

    
    
    #(result.Get("BookTitle"))#
    • 1
    • 2
    • 3
    • 4
    • 5
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    3. 将服务器端的代码传到浏览器时,对编码进行转换

    a.将value变量的值转化为HTML编码,并传递到客户端

    
    
    • 1

    value为 ,则浏览器端代码为:

    
    
    • 1

    b.x变量的值转化为URL编码,并传递到客户端

    Link
    
    • 1

    x 为100%,则浏览器端代码为:

    Link
    
    • 1

    三、前端到后台的交互(浏览器主动)

    1.表单提交

    a.浏览器端:

    User Name:
    • 1
    • 2
    • 3
    • 4

    b.服务端接受:

    %request.Data可以获取表单的参数,也可以获取URL传入的参数

    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    2.#Call调用(调用服务端方法)

    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    Customer Name:
    • 1
    • 2
    • 3
    • 4
    • 5
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    3.#Server调用(调用服务端方法)

    
    
    
    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    
    
    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    二、其他

    1. 引入固定的角本文件[撑握]

    
    
    
    
    	自动生成医嘱规则 
    
    
    
    // 省略其他代码...
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    dhan.csr

    
    
    	
    
    
    
    
    
    	
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    2. %session[撑握]

    获取Session信息

    %session.Data("value")
    
    • 1

    3. %Resquest

    获取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
    
    • 1
    • 2
    • 3
    • 4
    • 5

    4.%response

    a. 跳转
    Set %response.ServerSideRedirect = "C:\CacheSys\csp\samples\redirect.csp"
    
    • 1

    5. 获取客户端信息[了解]

    %SYSTEM.Process
    获取客户端IP地址:

    ##class(%SYSTEM.Process).ClientIPAddress($j)
    
    • 1
    方法名说明
    ClientIPAddress获取客户端IP地址
    ClientNodeName获取客户端主机名称

    6. 获取服务端信息[了解]

    获取服务端IP:

    %request.CgiEnvs("SERVER_NAME")
    %request.CgiEnvs("SERVER_ADDR")
    
    • 1
    • 2

    其他:

    方法名说明
    EnvironmentVariable Value
    AUTH_PASSWORDValue entered in the client’s authentication dialog. This variable is available only if Basic authentication is used.
    AUTH_TYPEContains the authentication method that the server uses to validate users when they attempt to access a protected script.
    CONTENT_TYPEFor requests which have attached information, such as HTTP POST and PUT, this is the content type of the data.
    GATEWAY_INTERFACERevision of the CGI specification to which this server complies. Format: CGI/revision
    HTTP_ACCEPTValue 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_CHARSETComma-delimited list of the character encodings that the client accepts.
    HTTP_ACCEPT_LANGUAGEContains a string describing the language to use for displaying content (such as en-us).
    HTTP_AUTHORIZATIONContains the Base-64 encoded username, password, scheme and realm sent by the client.
    HTTP_COOKIEHolds the contents of the client’s cookie(s).
    HTTP_REFERERHolds 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_SOAPACTIONSOAPAction 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_AGENTBrowser the client is using to send the request. General format: software/version library/version.
    HTTPSSet 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_TRANSLATEDTranslated version of PATH_INFO, in which any virtual-to-physical mapping is applied to the path.
    REMOTE_ADDR客户端IP地址
    REMOTE_HOSTHostname making the request. If the server does not have this information, it should set REMOTE_ADDR and leave this parameter unset.
    REMOTE_IDENTIf the HTTP server supports RFC 931 identification, then this variable is set to the remote username retrieved from the server.
    REMOTE_USERName of the user as it is derived from the authorization header sent by the client
    REQUEST_METHODHTTP 方法, GET, HEAD, POST,等.
    SERVER_NAME服务器名称,或DNS别名,IP地址
    SERVER_PORT服务器端口,如: 80
    SERVER_PORT_SECURESet 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_PROTOCOLName and revision of the information protocol that the request came in with. Format: protocol/revision
    SERVER_SOFTWAREWeb server 名称和软件版本 格式: 名称/版本
  • 相关阅读:
    智慧公厕领先品牌:卫生、智能、环保
    【软考-软件设计师精华知识点笔记】第七章 面向对象技术
    hive 导入数据的5种方式
    贪吃蛇-第12届蓝桥杯Scratch选拔赛真题精选
    基于文本提示的图像目标检测与分割实践
    LeetCode 热题 HOT 100 第八十五天 560. 和为 K 的子数组 用python3求解
    Linux系统下邮件服务器的搭建(Postfix+Dovecot+SSL)
    第五章:将组件库发布到npm【前端工程化入门-----从零实现一个react+ts+vite+tailwindcss组件库】
    原型模式(Clone)——创建型模式
    Nginx详解 第五部分:Ngnix反向代理(负载均衡 动静分离 缓存 透传 )
  • 原文地址:https://blog.csdn.net/aa_qq110/article/details/127593737