0

I have Liferay 7.2.

I created a module rest.

It is possibile to save a variable in session ad use it in other method?

My idea of code is:

@GET
@Path("/save/paramt")
            
public String jsonSaveParamRequest() throws Exception {

String json = "xx";

//SAVE IN SESSION json

return "ok";
}

@GET
@Path("/get/paramt")        
public String jsonGetParamRequest() throws Exception {
String xx= SESSION VARIABLE json

return xx;
}
MarioProject
  • 417
  • 4
  • 25

1 Answers1

0

Saving state in a HTTP session in a REST API is not recommended and should be avoided. Please refer to the discussions here SO:how-to-understand-restful-api-is-stateless.

Technically, I guess this is possible as you can inject the HttpServletRequest as a method param via @Context HttpServletRequest request to your annotated method and use getSession(). But I am not sure if you can rely on that.

Andre Albert
  • 1,386
  • 8
  • 17