• Post Reply Bookmark Topic Watch Topic
  • New Topic

Refresh Command come under page scope or request scope  RSS feed

 
Bhawna Gupta
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have doubt related refresh command. When we refresh web page then this is a new request.But this request come under page scope or request scope.

Thanks in advance.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean when the user presses the refresh button on their browser? This causes a new request to be sent to the server. This doesn't 'come under' either the page or the request scope. It does create a new request scope, though, since it creates a new request. Since the request will probably generate at least one JSP page (and thus a new PageContext), one or more page scopes would also likely be created.
 
Bhawna Gupta
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Steve,

Still i have some doubts.Can you please explain through example.
Thanks
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you ask a specific question, because there is not much to explain. A refresh sends a request, you already know that. I assume you know what the request scope is, and what the page scope is, if not maybe the JEE Tutorial will help (I am not sure, haven't used it in a while). So what exactly are you having trouble with?
 
Bhawna Gupta
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ,

Refresh command do not send the request to the server because its cookie generated on our system.
Request Scope is used ----when we want to forward our request on the new web page.

My Question is ----I want some information will retain on that page after refreshing a page. Then that value will stored in page scope or request scope.
I think request scope is used when we want to open different web page and page scope is used --when we want to open same page(in case of refresh also).

If i am incorrect .Please correct me and give the answer of my question.


Thanks
 
Balaji Vankadaru
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request Object

Each time a client requests a page the JSP engine creates a new object to represent that request.

The request object provides methods to get HTTP header information including form data, cookies, HTTP methods.

Page Object

This object is an actual reference to the instance of the page. It can be thought of as an object that represents the entire JSP page.

The page object is really a direct synonym for the this object.


 
Bhawna Gupta
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

It means the answer of my question "My Question is ----I want some information will retain on that page after refreshing a page. Then that value will stored in page scope or request scope " is i will store that information on request scope which i want to retain on refreshing.

Thanks
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bhawna Gupta wrote:Refresh command do not send the request to the server

False. A Refresh is a button, built into the browser, which sends a new request to the server using the same URL as is currently displayed in the browsers.
because its cookie generated on our system.

Not exactly sure what you mean by this, but I think it means you also don't understand what a cookie is. A cookie is made by the server and sent to the client (the browser) as part of the response. Any subsequent requests to the same server (from the client) will be accompanied by sending the cookie BACK to the server. The server then uses the cookie it got as part of the request to identify the request as having coming back from the same user as the previous request.

Request Scope is used ----when we want to forward our request on the new web page.
Request scope is used when the data should exist for the entire length of a single request, regardless of how many Servlets or JSPs are touched along the process of the request.

My Question is ----I want some information will retain on that page after refreshing a page. Then that value will stored in page scope or request scope.

Neither. The request scope lasts for one request. A page scope is smaller, lasting for the life of one JSP being processed. A refresh creates a new request, so any data stored in the request scope would be lost as a new request scope would be made.

What you want to use is the Session scope. A session scope lasts as long as the user is 'connected' to the service. In reality there is a Session object that is stored and has a configurable time out. The user's session is maintained by either a cookie or by encoded URLs, and as long as the user accesses the service with a request that contains the cookie or encoding before the timeout occurs, the Session scope is still available to store and access data.

I think request scope is used when we want to open different web page and page scope is used --when we want to open same page(in case of refresh also).

Page scope would be used to store data in a JSP between the start of page processing and end of the page processing. It is akin to a 'local variable' in a method. The request scope is used for sharing data from servlets, filters, and JSPs. It is sort of akin to making a data transfer object that collects data from a database, passes it around to multiple methods, and then thrown away when the data is no longer in use. It becomes no longer in use when the response is made / finalized to the client.
 
Bhawna Gupta
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

You clear all my doubts.Thanks for giving the full explanation.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!