| | | | Question Answer Tutorial - JAVA->SERVLET | | | | Question: What is different between web server and application server? | | Answer: A web server responsibility is to handler HTTP requests  ;from client browsers and respond with HTML />response. A web server understands HTTP language and runs& nbsp;on HTTP protocol.
/>Apache Web Server is kind of a web server and th en we have specific containers that can execute />servlets and JSPs known as servlet container, for example& nbsp;Tomcat.
/>Application Servers provide additional features such as Enterpr ise JavaBeans support, JMS Messaging />support, Transaction Management etc. So we can say that&nb sp;Application server is a web server with />additional functionalities to help developers with enterprise a pplications.
| | | | | | | | Question: Which HTTP method is non-idempotent?
| | Answer: A HTTP method is said to be idempotent if it retur ns the same result every time. HTTP methods GET, />PUT, DELETE, HEAD, and OPTIONS are idempotent method and&n bsp;we should implement our application to make />sure these methods always return same result. HTTP method& nbsp;POST is non-idempotent method and we />should use post method when implementing something that ch anges with every request.
/>For example, to access an HTML page or image, we  ;should use GET because it will always return the />same object but if we have to save customer informati on to database, we should use POST method. />Idempotent methods are also known as safe methods and  ;we don’t care about the repetitive request />from the client for safe methods.
| | | | | | | | Question: What is the difference between GET and POST method?
| | Answer: GET is a safe method (idempotent) where POST is non-ide mpotent method
/>We can send limited data with GET method and it’s&nbs p;sent in the header request URL whereas we can send />large amount of data with POST because it’s part of&n bsp;the body
/>GET method is not secure because data is exposed in&n bsp;the URL and we can easily bookmark it and send />similar request again, POST is secure because data is  ;sent in request body and we can’t bookmark it
/>GET is the default HTTP method whereas we need to&nbs p;specify method as POST to send request with POST />method
Hyperlinks in a page uses GET method
| | | | | | | | Question: What is MIME Type? | | Answer: The "Content-Type" response header is known as MIME Type.&nb sp;Server sends MIME type to client to let />them know the kind of data it’s sending. It helps&nbs p;client in rendering the data for user. Some of the />mostly used mime types are text/html, text/xml, application/xml etc.
/>We can use ServletContext getMimeType() method to get the& nbsp;correct MIME type of the file and use it />to set the response content type. It’s very useful in downloading file through servlet from server.
| | | | | | | | Question: What is a web application and what is it’s directory structure?
| | Answer: Web Applications are modules that run on server to prov ide both static and dynamic content to the />client browser. Apache web server supports PHP and we  ;can create web application using PHP. Java />provides web application support through Servlets and JSPs  ;that can run in a servlet container and />provide dynamic content to client browser.
/>Java Web Applications are packaged as Web Archive (WAR)&nb sp;and it has a defined structure like below image.
/> Servlet01
| | | | | | | | | | | | |