on ‎2020 Dec 04 9:49 PM
I'm building a simple SAPUI5 app.
The app requests data from a back-end server, written with Java EE. I use Servlets as endpoint, because I want to maintain a session but it seems not to work.
When I call a servlet after login, the method
request.getSession(false)
in the servlet returns null.
When I test the back-end server with Postman, it works.
I really don't know how to solve.
I'm using SAP Web IDE Personal Edition.
Thanks in advance.
Request clarification before answering.
I solved by setting cors.support.credentials = true and setting cors.allowed.origins = sapui5_app_address in web.xml file like this
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>http://localhost:55616</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
</filter>and by adding
xhrFields: {
withCredentials: true
}to JQuery.ajax() request object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.