• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

confused about difference between doGet/doPost methods and request/response variables  RSS feed

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, we have request and response local variable parameters in doGet and doPost method like this -

doGet -


doPost -



doPost method is used- when we want to write the data to the server
doGet method is used - when we want to fetch the data from the server
The what  request and response variables do.
i guess request - fetches the data from the page
and response - writes the data back to the page
.
here request variable does the same job as doGet method and doPost does the same job as response. then y are the local variables used. I have confusion amongst their working.
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sucheta Shrivastava wrote:doPost method is used- when we want to write the data to the server


Sort of, but that's not complete. Essentially a POST is used when an operation is to be performed -- to include writing data.

doGet method is used - when we want to fetch the data from the server


Pretty much.

An important point to note is that GETs must be idempotent: that is, the same GET made again and again returns the same value. POSTs do not have this restriction.

The [sic] what  request and response variables do.


The request instance represents the HTTP request made to the server from the client. It contains all the information for the request: parameters, method, headers, and so on.

and response - writes the data back to the page


The response instance represents the HTTP response that will be sent to the client from the server. Note I didn't use the word "page". The client can be anything, not just a browser.

here request variable does the same job as doGet method and doPost does the same job as response.


No. The request and response are the same for all methods, including GET and POST. See above.

then y are the local variables used. I have confusion amongst their working.


Please use real words when posting. "why" not "y". Thanks.

Local variables defined within the methods are there for the method to use internally to do whatever it needs to do, just as with any other Java class methods. They have no bearing outside the method and are discarded when the method exits.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!