This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Request scope and Session scope

 
shaiksha vali
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any one tell about difference between Request Scope and Session Scope in struts

Example:

 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you will get more from below link .!!

JavaBeans and Scope
 
Vinod Vinu
Ranch Hand
Posts: 217
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)

for more info:-
http://struts.apache.org/1.x/userGuide/building_model.html

If you still have any queries, you can reply to me
 
shaiksha vali
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank q
 
Krish Khan
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Vinod!

Can you please let me know reagrding the session n request.

I am using struts 1 framework , SQl DB.

Performance wise which is best to use. Present I am retrieving data from database and storing it in arraylist and then keeping tht arraylist in session and displaying it .

Its giving me performance issue . So can i try request?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Krish Khan wrote:Its giving me performance issue . So can i try request?

It is highly unlikely that will matter. The only way session matters is if:
1) you are storing so much in it that you are running out of memory
2) you have session replication enabled and are transferring the session across the network

It is much more likely the bottleneck is in the database or file processing layer. I recommend profiling or at least adding some printlns.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic