> For the complete documentation index, see [llms.txt](https://gyansetu-jspandservlets-for-java.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-jspandservlets-for-java.gitbook.io/workspace/understanding-get-and-post.md).

# Understanding GET and POST

### GET : is used to get resource from the server:

Ex : Just change the method from post to get in the form and hit the URL.

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoT6fnej3ItsX3CyPc%2FScreen%20Shot%202019-04-19%20at%2012.50.20%20PM.png?alt=media\&token=d5f92fe4-5468-432e-88d0-a0d45ac24068)

#### Observation :

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoTCPPnATPSExNlIz_%2FScreen%20Shot%202019-04-19%20at%2012.50.58%20PM.png?alt=media\&token=51284c79-94a6-47a2-8fa4-b7eb6ec394ba)

#### URL after submitting form :

```markup
http://localhost:8080/SimpleServletProject/xmlservletpath?userName=Mohit&lastName=malhotra&profession=Manager&countries=India&cities=Mumbai
```

1\) All the parameters are sent as query parameters in the GET request.

2\) Refresh the browser and the GET operation will have same effect , browser will not warn us.

### POST : is user to create resource on the server:

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoUFtCaJWpYB3oK0Ib%2FScreen%20Shot%202019-04-19%20at%2012.53.38%20PM.png?alt=media\&token=62365623-62a0-420a-9989-d63adb545f87)

#### Observation :

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoUIkpMnkvGEjnTOv1%2FScreen%20Shot%202019-04-19%20at%2012.54.04%20PM.png?alt=media\&token=deaf4180-7d13-454a-a123-d6481f6196fc)

On Refreshing we got the confirm  Resubmission  message from the browser :

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoUOcHzE7pmI5ForYn%2FScreen%20Shot%202019-04-19%20at%2012.54.30%20PM.png?alt=media\&token=154ffd45-0851-475b-aa1d-18d2b9612ac3)

### HttpServlet is a java specification :

#### Download Apache tomcat Doc : ( from source code distribution)

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoW_Nb3xXt49bVYhmW%2FScreen%20Shot%202019-04-19%20at%201.01.56%20PM.png?alt=media\&token=263fa497-6629-46c6-adf0-ca2688659c83)

#### Extract it

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoWguBQDsi9RQyp1Xv%2FScreen%20Shot%202019-04-19%20at%201.02.35%20PM.png?alt=media\&token=c9bf16ef-2934-4fa8-8909-d3c23e7c62c7)

#### Attach source : (Option will come when you try to open HttpServlet class )

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoWmxSVXHu96AMHN-O%2FScreen%20Shot%202019-04-19%20at%201.02.16%20PM.png?alt=media\&token=aa4e9872-77e5-471e-99eb-c9630fa5051d)

#### Check all the methods of HttpServlet provided by Tomcat:

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LcoS_3Z7c64LTxFOJMb%2F-LcoWykqsUgqOUnZTe62%2FScreen%20Shot%202019-04-19%20at%201.03.19%20PM.png?alt=media\&token=bd918c48-c7a0-4bf6-9922-7d57e9eb6255)

{% hint style="warning" %}
If we do not override doGet or doPost method then tomcat will call its own doGet or doPost methods.
{% endhint %}
