0

Is the Model.class(or request scope) affected in any way by the current session or actions done to that current session?

One scenario below,

Real life application would be request->user logging off-> request access.

model.addAttribute("inputForm",inputForm);
session.invalidate(); 
if(model.containsAttribute("inputForm")) //true or false?

Some artifact I have dug up,

" In struts-config.xml scope = "session" means throught the application ( till the session gets expired). Your can keep the values in session no matter how many JPSs you are visiting of that application. It remains there in session until you close your browser.

scope="request" means for that particular action only you are keeping the values. In this if you call another action or redirects to another JSP , it gets removed.

Another difference is that :- request - Beans that are visible within a single JSP page, as well as to any page or servlet that is included in this page, or forwarded to by this page. (Request attributes)

session - Beans that are visible to all JSP pages and servlets that participate in a particular user session, across one or more requests. (Session attributes) "- http://www.coderanch.com/t/462078/Struts/Difference-Request-scope-Session-scope - Vinod Vinu

More about scopes How to choose the right bean scope?

Community
  • 1
  • 1
Jared Teng
  • 311
  • 1
  • 5
  • 21
  • Interesting question. What did you find? – Sanjay Aug 09 '15 at 16:17
  • @Sanjay I'll add in edit things I can dig up. Although they don't directly answer the question, but gives a direction in a way. – Jared Teng Aug 09 '15 at 16:18
  • In a way, they seem to be apples and oranges but I my self can't confirm them to not affect each other(not to mention I haven't really found definitive proof). I'll see if someone with better background can swoop in. – Jared Teng Aug 09 '15 at 16:30
  • Model and session aren't related in that way. So in this case it still would be there. The Model is a separate object regardless of the scope it is used in. Basically the model is completely unaware of the underlying technology it is used with. – M. Deinum Aug 10 '15 at 05:48
  • @M. Deinum I'll second that, with today's experiments. Session and request scopes are like apples and oranges, I invalidated session and it did not have an effect to request scope. Please put it as answer and I shall make it so. – Jared Teng Aug 10 '15 at 06:07

0 Answers0