permaculture playing cards*
The moose likes Struts and the fly likes Difference between Request scope and Session scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Difference between Request scope and Session scope" Watch "Difference between Request scope and Session scope" New topic

Difference between Request scope and Session scope

shaiksha vali

Joined: Jul 12, 2009
Posts: 11
Could any one tell about difference between Request Scope and Session Scope in struts


Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

May be you will get more from below link .!!

JavaBeans and Scope

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
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.

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:-

If you still have any queries, you can reply to me

Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
shaiksha vali

Joined: Jul 12, 2009
Posts: 11
thank q
Krish Khan
Ranch Hand

Joined: Dec 14, 2009
Posts: 46
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
internet detective

Joined: May 26, 2003
Posts: 30057

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.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Difference between Request scope and Session scope
Similar Threads
difference between page and request
Do I understand scope, redirects and JSPs correctly?
What is the difference between Request Session and Portlet Session?
Bean Scope
Application and Request Scope