SAP BSP应用有状态和无状态行为差异比较
In previous blog Fiori and CRM WebClient UI – Stateless and Stateful, but how? I have researched how stateful and stateless BSP application are handled in ABAP server side. In this blog I will explain how stateful and stateless BSP application behave differently.
The test BSP application I am using
It consists of three files.
first.json
<%@page language="abap" %>
<%
WAIT UP TO 3 SECONDS.
%>
{
"message":"First page wait 3 seconds"
}
Here I use WAIT keyword to simulate that it will take 3 seconds for the first request to finish.
index.html
In this html file, I fire two requests to fetch “first.json” and “second.json” one by one. The first request is sent before second request.
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<!DOCTYPE html>
<html>
<head>
<title>Jerry Test Stateful</title>
</head>
<body>
<button onclick="fire()">Fire two request</button>
<script>
function wrapperOnFetch(url){
fetch(url,{ credentials:"include" }).then(function(response){
return response.json();
}).then(function(json){
console.log(url + ":" + json.message);
});
}
function fire(){
wrapperOnFetch("first.json");
wrapperOnFetch("second.json");
}
</script>
</body>
</html>
second.json
<%@page language="abap"%>
{
"message":"Second page no wait to response"
}
The application is firstly set as Stateful:
Stateful test
(1) Launch index.html, and in Chrome development tool you can see there are three “set-cookie” in Response Header fields.
One of them, the sap-contextid is set in method ON_REQUEST_LEAVE of CL_BSP_RUNTIME explained in previous blog.
And you can observe the cookie in tab “Application”:
The cookie could also be reviewed in Chrome via Settings ->Advanced Settings->Privacy->Content Settings->All cookies and site data…
(2) click button “Fire two request”, and in console we can observe that these two requests are handled sequentially in server: the response of first request still comes first before the response of second request.
This could also be confirmed in the Network tab. The first request takes totally 3 seconds to finish. During the wait of this 3 seconds, the process of second request is pending till the first request finishes. As a result finally both request takes around 3 seconds to get handled.
We can also observe that the cookie set by index.html load is now automatically appended as the request header for “first.json” and “second.json” request:
Stateless test
Now set application as stateless and open index.html again:
Compare the cookie with stateful test, this time the cookie
sap-contextid is not there. This observation is consistent with what I found in blog Fiori and CRM WebClient UI – Stateless and Stateful, but how?, as it will only be set in stateful application.
Click fire button, and we can find in stateless application, these two requests are handled by server in parallel: the response of second request is now coming first before the response of first request.
In Network tab, once fire button is clicked, the second request gets processed almost immediately, and the first request still has status “Pending”.
After 3 seconds the first request is done, total duration is around 3 seconds:
In Stateless application, it is clearly observed that cookie field sap-contextid is not involved in the request & response handling.
- datalist标签小结
- Java常用工具类之删除文件
- Java常用工具类之Excel导出
- js行内式遇到的一些问题 DOM对象和jq对象转换的问题
- JavaWeb(三)servlet
- PL/SQL 编程(三 )程序包和包体,触发器,视图,索引
- 一次关于js事件出发机制反常的解决记录
- Java综合题目
- Ubuntu 16.04下为TITAN 1080 显卡安装驱动及Gpu版TensorFlow|深度学习
- 给新生成的节点(动态生成节点)绑定事件方法总结
- JavaWeb(四)JDBC操作Oracle
- JavaWeb(六)Listener监听器
- JSP引入 - UEditor 富文本编辑器
- JavaWeb(五)Filter过滤器
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- spring之为什么要使用AOP(面向切面编程)?
- useContext更佳实践
- 【论文笔记】张航和李沐等提出:ResNeSt: Split-Attention Networks(ResNet改进版本)
- [前端]GOFLY项目-响应式登录页的设计和实现
- [GO] golang练习项目-gorm与mysql的增删查改操作
- 设计模式~门面模式
- c语言之define和typedef的区别
- TSINGSEE青犀视频官网全新改版即将上线,系统界面迎来整体升级
- c语言之带参数的宏定义
- spring AOP之基于xml配置文件的方式来配置AOP
- 基于TypeScript封装Axios笔记(五)
- spring之操作数据库之使用JdbcTemplate和JdbcDaoSupport
- 修改Markdown神器[Typora]的主题样式
- 视频压缩原理入门
- spring之为什么要使用事务?(一)