<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Madanswer Technologies Interview Questions Data|Agile|DevOPs|Python - Recent questions and answers in Servlet</title>
<link>https://madanswer.com/qa/servlet</link>
<description>Powered by Question2Answer</description>
<item>
<title>Answered: What is difference between Get and Post method?</title>
<link>https://madanswer.com/72175/what-is-difference-between-get-and-post-method?show=79667#a79667</link>
<description>
&lt;p&gt;Get method allows you to send a limited amount of data in the header. Post allows you to send a large amount of data in the body.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;
</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72175/what-is-difference-between-get-and-post-method?show=79667#a79667</guid>
<pubDate>Sun, 22 Oct 2023 14:10:51 +0000</pubDate>
</item>
<item>
<title>Answered: What is the use of attribute in servlets?</title>
<link>https://madanswer.com/72221/what-is-the-use-of-attribute-in-servlets?show=72222#a72222</link>
<description>&lt;p&gt;Attribute is a map object that can be used to set, get or remove in request, session or application scope. It is mainly used to share information between one servlet to another.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72221/what-is-the-use-of-attribute-in-servlets?show=72222#a72222</guid>
<pubDate>Wed, 12 Apr 2023 20:58:54 +0000</pubDate>
</item>
<item>
<title>Answered: What is the use of welcome-file-list?</title>
<link>https://madanswer.com/72219/what-is-the-use-of-welcome-file-list?show=72220#a72220</link>
<description>&lt;p&gt;It is used to specify the welcome file for the project.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72219/what-is-the-use-of-welcome-file-list?show=72220#a72220</guid>
<pubDate>Wed, 12 Apr 2023 20:58:29 +0000</pubDate>
</item>
<item>
<title>Answered: Which event is fired at the time of setting, getting or removing attribute from application scope?</title>
<link>https://madanswer.com/72217/which-event-fired-time-setting-getting-removing-attribute-from-application-scope?show=72218#a72218</link>
<description>&lt;p&gt;ServletContextAttributeEvent.&lt;span style=&quot;color:#000000; font-family:Arial,sans-serif; font-size:18px&quot;&gt;event is fired at the time of setting, getting or removing attribute from application scope&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72217/which-event-fired-time-setting-getting-removing-attribute-from-application-scope?show=72218#a72218</guid>
<pubDate>Wed, 12 Apr 2023 20:58:04 +0000</pubDate>
</item>
<item>
<title>Answered: Which event is fired at the time of session creation and destroy?</title>
<link>https://madanswer.com/72215/which-event-is-fired-at-the-time-of-session-creation-and-destroy?show=72216#a72216</link>
<description>&lt;p&gt;HttpSessionEvent.&lt;span style=&quot;color:#000000; font-family:Arial,sans-serif; font-size:18px&quot;&gt;is fired at the time of session creation and destroy&lt;/span&gt;&lt;/p&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72215/which-event-is-fired-at-the-time-of-session-creation-and-destroy?show=72216#a72216</guid>
<pubDate>Wed, 12 Apr 2023 20:57:29 +0000</pubDate>
</item>
<item>
<title>Answered: Which event is fired at the time of project deployment and undeployment?</title>
<link>https://madanswer.com/72213/which-event-is-fired-at-the-time-of-project-deployment-and-undeployment?show=72214#a72214</link>
<description>&lt;p&gt;ServletContextEvent.&lt;span style=&quot;color:#000000; font-family:Arial,sans-serif; font-size:18px&quot;&gt;event is fired at the time of project deployment and undeployment&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72213/which-event-is-fired-at-the-time-of-project-deployment-and-undeployment?show=72214#a72214</guid>
<pubDate>Wed, 12 Apr 2023 20:56:55 +0000</pubDate>
</item>
<item>
<title>Answered: What are the annotations used in Servlet 3?</title>
<link>https://madanswer.com/72211/what-are-the-annotations-used-in-servlet-3?show=72212#a72212</link>
<description>There are mainly 3 annotations used for the servlet.&lt;br /&gt;
&lt;br /&gt;
@WebServlet : for servlet class.&lt;br /&gt;
&lt;br /&gt;
@WebListener : for listener class.&lt;br /&gt;
&lt;br /&gt;
@WebFilter : for filter class.</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72211/what-are-the-annotations-used-in-servlet-3?show=72212#a72212</guid>
<pubDate>Wed, 12 Apr 2023 20:56:24 +0000</pubDate>
</item>
<item>
<title>Answered: How to create war file?</title>
<link>https://madanswer.com/72209/how-to-create-war-file?show=72210#a72210</link>
<description>&lt;p&gt;The war file can be created using jar tool found in jdk/bin directory. If you are using Eclipse or Netbeans IDE, you can export your project as a war file.&lt;/p&gt;&lt;p&gt;To create war file from console, you can write following code.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;jar -cvf abc.war *&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now all the files of current directory will be converted into abc.war file.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72209/how-to-create-war-file?show=72210#a72210</guid>
<pubDate>Wed, 12 Apr 2023 20:55:34 +0000</pubDate>
</item>
<item>
<title>Answered: What is war file?</title>
<link>https://madanswer.com/72207/what-is-war-file?show=72208#a72208</link>
<description>&lt;p&gt;A war (web archive) file specifies the web elements. A servlet or jsp project can be converted into a war file. Moving one servlet project from one place to another will be fast as it is combined into a single file.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72207/what-is-war-file?show=72208#a72208</guid>
<pubDate>Wed, 12 Apr 2023 20:55:11 +0000</pubDate>
</item>
<item>
<title>Answered: What if we pass negative value in load-on-startup?</title>
<link>https://madanswer.com/72205/what-if-we-pass-negative-value-in-load-on-startup?show=72206#a72206</link>
<description>&lt;p&gt;It will not affect the container, now servlet will be loaded at first request.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72205/what-if-we-pass-negative-value-in-load-on-startup?show=72206#a72206</guid>
<pubDate>Wed, 12 Apr 2023 20:54:51 +0000</pubDate>
</item>
<item>
<title>Answered: What is load-on-startup in servlet?</title>
<link>https://madanswer.com/72203/what-is-load-on-startup-in-servlet?show=72204#a72204</link>
<description>&lt;p&gt;The load-on-startup element of servlet in web.xml is used to load the servlet at the time of deploying the project or server start. So it saves time for the response of first request.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72203/what-is-load-on-startup-in-servlet?show=72204#a72204</guid>
<pubDate>Wed, 12 Apr 2023 20:54:18 +0000</pubDate>
</item>
<item>
<title>Answered: How can we upload the file to the server using servlet?</title>
<link>https://madanswer.com/72201/how-can-we-upload-the-file-to-the-server-using-servlet?show=72202#a72202</link>
<description>&lt;p&gt;One of the way is by MultipartRequest class provided by third party.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72201/how-can-we-upload-the-file-to-the-server-using-servlet?show=72202#a72202</guid>
<pubDate>Wed, 12 Apr 2023 20:53:56 +0000</pubDate>
</item>
<item>
<title>Answered: What is the disadvantage of cookies?</title>
<link>https://madanswer.com/72199/what-is-the-disadvantage-of-cookies?show=72200#a72200</link>
<description>It will not work if cookie is disabled from the browser.</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72199/what-is-the-disadvantage-of-cookies?show=72200#a72200</guid>
<pubDate>Wed, 12 Apr 2023 20:53:38 +0000</pubDate>
</item>
<item>
<title>Answered: How can we perform any action at the time of deploying the project?</title>
<link>https://madanswer.com/72197/how-can-we-perform-any-action-at-the-time-of-deploying-the-project?show=72198#a72198</link>
<description>&lt;p&gt;By the help of ServletContextListener interface.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72197/how-can-we-perform-any-action-at-the-time-of-deploying-the-project?show=72198#a72198</guid>
<pubDate>Wed, 12 Apr 2023 20:53:16 +0000</pubDate>
</item>
<item>
<title>Answered: What is filter?</title>
<link>https://madanswer.com/72195/what-is-filter?show=72196#a72196</link>
<description>&lt;p&gt;A filter is an object that is invoked either at the preprocessing or postprocessing of a request. It is pluggable.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72195/what-is-filter?show=72196#a72196</guid>
<pubDate>Wed, 12 Apr 2023 20:52:50 +0000</pubDate>
</item>
<item>
<title>Answered: What is difference between Cookies and HttpSession?</title>
<link>https://madanswer.com/72193/what-is-difference-between-cookies-and-httpsession?show=72194#a72194</link>
<description>&lt;p&gt;Cookie works at client side whereas HttpSession works at server side.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72193/what-is-difference-between-cookies-and-httpsession?show=72194#a72194</guid>
<pubDate>Wed, 12 Apr 2023 20:52:22 +0000</pubDate>
</item>
<item>
<title>Answered: What are Cookies in servlet?</title>
<link>https://madanswer.com/72191/what-are-cookies-in-servlet?show=72192#a72192</link>
<description>&lt;p&gt;A cookie is a small piece of information that is persisted between the multiple client requests. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72191/what-are-cookies-in-servlet?show=72192#a72192</guid>
<pubDate>Tue, 11 Apr 2023 19:47:25 +0000</pubDate>
</item>
<item>
<title>Answered: What is Session Tracking?</title>
<link>https://madanswer.com/72189/what-is-session-tracking?show=72190#a72190</link>
<description>&lt;p&gt;Session simply means a particular interval of time.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Session Tracking is a way to maintain state of an user.Http protocol is a stateless protocol.Each time user requests to the server, server treats the request as the new request.So we need to maintain the state of an user to recognize to particular user.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72189/what-is-session-tracking?show=72190#a72190</guid>
<pubDate>Tue, 11 Apr 2023 19:46:47 +0000</pubDate>
</item>
<item>
<title>Answered: Difference between forward() method and sendRedirect() method ?</title>
<link>https://madanswer.com/72187/difference-between-forward-method-and-sendredirect-method?show=72188#a72188</link>
<description>&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;The difference between SendRedirect and forward is one of the classical interview questions asked during a java web developer interview. This is not just applicable for servlet but also for JSP in which we can use forward action or call sendRedirect() method from scriptlet. Before examining the difference between forward and SendRedirect let’s see what send Redirect method and the forward method does.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;div id=&quot;vdo_ai_div&quot; style=&quot;width: 2350px; margin-top: 20px; direction: ltr !important;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;strong&gt;&lt;u&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;SendRedirect ():&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;This method is declared in HttpServletResponse&lt;strong&gt;&amp;nbsp;Interface&lt;/strong&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;&lt;strong&gt;Signature&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;:&amp;nbsp;&lt;span style=&quot;font-family:&amp;quot;courier new&amp;quot;,courier,monospace&quot;&gt;void sendRedirect(String url)&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;a name=&quot;more&quot; id=&quot;more&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;http://javarevisited.blogspot.com/2011/09/javalangoutofmemoryerror-permgen-space.html&quot; style=&quot;color: rgb(0, 102, 204); clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;difference between sendRedirect and forward in jsp servlet&quot; border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-wrzDeQGAe1I/TWu8pLuLr4I/AAAAAAAAADE/V017G-6Q61w/s1600/java_logo_50_50.jpg&quot; style=&quot;border-width:0px&quot;&gt;&lt;/a&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;This method is used to redirect the client requests to some other location for further processing&lt;strong&gt;,&amp;nbsp;&lt;/strong&gt;the new location is available on different servers or different contexts.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Our web container handles this and transfers the request using a browser, and this request is&amp;nbsp;&lt;strong&gt;visible in the browser as a new request&lt;/strong&gt;. Sometimes this is also called a client-side redirect.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;strong&gt;&lt;u&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Forward():&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;This method is declared in&amp;nbsp;&lt;span style=&quot;font-family:&amp;quot;courier new&amp;quot;,courier,monospace&quot;&gt;RequestDispatcher&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;Interface.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Signature&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;:&lt;span style=&quot;font-family:&amp;quot;courier new&amp;quot;,courier,monospace&quot;&gt;&amp;nbsp;forward(ServletRequest request, ServletResponse response)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div id=&quot;s-javarevisited-blogspot-0&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small; width: 2350px; margin-left: 0px;&quot;&gt;&lt;div id=&quot;storiesUnitDivWrapper-0&quot; style=&quot;width: 2350px; min-height: 250px;&quot;&gt;&lt;/div&gt;&lt;div id=&quot;vdo_companion_wrapper&quot; style=&quot;text-align: center; margin-top: 10px;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small; display: table; margin-left: auto; margin-right: auto;&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;This method is used to pass the request to another resource for further processing&amp;nbsp;&lt;strong&gt;within the same server&lt;/strong&gt;, another resource could be any servlet, jsp page any kind of file.&lt;/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;This process is taken care of by a web container when we call forward method request is sent to another resource&amp;nbsp;&lt;strong&gt;without the client being informed,&lt;/strong&gt;&amp;nbsp;which resource will handle the request it has been mention on requestDispatcher object which we can get in two ways either using ServletContext or Request. This is also called a server-side redirect.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;pre class=&quot;hljs&quot; style=&quot;background: none 0% 0% repeat scroll rgb(240, 240, 240); color: rgb(68, 68, 68); overflow-x: auto; padding: 0.5em;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;RequestDispatcher rd = &lt;span style=&quot;color:#397300&quot; class=&quot;hljs-built_in&quot;&gt;request&lt;/span&gt;.getRequestDispatcher(&lt;span style=&quot;color:#880000&quot; class=&quot;hljs-string&quot;&gt;&quot;pathToResource&quot;&lt;/span&gt;);
rd.forward(&lt;span style=&quot;color:#397300&quot; class=&quot;hljs-built_in&quot;&gt;request&lt;/span&gt;, &lt;span style=&quot;color:#397300&quot; class=&quot;hljs-built_in&quot;&gt;response&lt;/span&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Or&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;pre class=&quot;hljs&quot; style=&quot;background: none 0% 0% repeat scroll rgb(240, 240, 240); color: rgb(68, 68, 68); overflow-x: auto; padding: 0.5em;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;RequestDispatcher rd = servletContext.getRequestDispatcher(&lt;span style=&quot;color:#880000&quot; class=&quot;hljs-string&quot;&gt;&quot;/pathToResource&quot;&lt;/span&gt;);
rd.forward(&lt;span style=&quot;color:#397300&quot; class=&quot;hljs-built_in&quot;&gt;request&lt;/span&gt;, &lt;span style=&quot;color:#397300&quot; class=&quot;hljs-built_in&quot;&gt;response&lt;/span&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;h2 style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;u&gt;Difference between SendRedirect and Forward&lt;/u&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Now let’s see some differences between these two methods of servlet API in tabular format.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse:collapse; border:medium none; color:#000000; font-family:&amp;quot;Trebuchet MS&amp;quot;,Verdana,Arial,sans-serif; font-size:small; border-spacing: 0px;&quot; class=&quot;MsoTableGrid&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border-style:solid; border-width:1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Forward()&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:solid solid solid none; border-width:1pt 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;SendRediret()&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-style:none solid solid; border-width:medium 1pt 1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;When we use the forward method request is transferred to other resources within the same server for further processing.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:none solid solid none; border-width:medium 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;In case of sendRedirect request is transferred to another resource to a different domain or different server for further processing.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-style:none solid solid; border-width:medium 1pt 1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;In case of forward Web container handle all process internally and client or browser is not involved.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:none solid solid none; border-width:medium 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;When you use the SendRedirect container transfers the request to the client or browser so url given inside the&amp;nbsp;&lt;strong&gt;sendRedirect&amp;nbsp;&lt;/strong&gt;method is visible as a new request to the client.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-style:none solid solid; border-width:medium 1pt 1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;When forward is called on&amp;nbsp;&lt;strong&gt;requestdispather&lt;/strong&gt;&amp;nbsp;object we pass request and response object so our old request object is present on new resource which is going to process our request&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:none solid solid none; border-width:medium 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;In case of SendRedirect call old request and response object is lost because it’s treated as new request by the browser.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-style:none solid solid; border-width:medium 1pt 1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Visually we are not able to see the forwarded address, its is transparent&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:none solid solid none; border-width:medium 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;In the address bar we are able to see the new redirected address it’s not transparent.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-style:none solid solid; border-width:medium 1pt 1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Using the forward () method is faster than send a redirect.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:none solid solid none; border-width:medium 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;SendRedirect is slower because one extra round trip is required because a completely new request is created and the old request object is lost. Two browser requests required.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-style:none solid solid; border-width:medium 1pt 1pt; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;When we redirect using forward and we want to use the same data in a new resource we can use the request.setAttribute () as we have request object available.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;border-style:none solid solid none; border-width:medium 1pt 1pt medium; padding:0in 5.4pt; vertical-align:top; width:221.4pt; width: 295px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;But in sendRedirect if we want to use we have to store the data in session or pass along with the URL.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;h2 style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;u&gt;Example of forwarding and SendRedirect in JSP Servlet:&lt;/u&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Any kind of online payment when we use the merchant site will redirect us to the net banking site which is a completely new request it processes our request and again redirect to the merchant site?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;In Banking Application when we do login normally we use the forward method. In the case of online banking, we are asked for a username and password if it’s correct some other servlet or resource will handle the request otherwise request has been forwarded to an error page.&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;h3 style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;Which one is good?&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;It depends upon the scenario that which method is more useful.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;If you want control is transfer to a new server or context and it is treated as a completely new task then we go for Send Redirect.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;Normally forward should be used if the operation can be safely repeated upon a browser reload of the web page will not affect the result.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;Trebuchet MS&amp;quot;, Verdana, Arial, sans-serif; font-size: small;&quot;&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;span style=&quot;font-family:verdana&quot;&gt;SendRedirect and forward methods are still very useful while programming or working on any web application project using&amp;nbsp;&lt;strong&gt;servlet jsp&lt;/strong&gt;. This is still a popular interview question so don’t forget to revise&amp;nbsp;&lt;strong&gt;forward and sendRedirect&lt;/strong&gt;&amp;nbsp;before appearing for any job interview.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72187/difference-between-forward-method-and-sendredirect-method?show=72188#a72188</guid>
<pubDate>Tue, 11 Apr 2023 19:46:21 +0000</pubDate>
</item>
<item>
<title>Answered: Can you call a jsp from the servlet?</title>
<link>https://madanswer.com/72185/can-you-call-a-jsp-from-the-servlet?show=72186#a72186</link>
<description>&lt;p&gt;Yes, one of the way is RequestDispatcher interface for example:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;RequestDispatcher rd=request.getRequestDispatcher(&quot;/login.jsp&quot;);&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;rd.forward(request,response);&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72185/can-you-call-a-jsp-from-the-servlet?show=72186#a72186</guid>
<pubDate>Tue, 11 Apr 2023 19:45:15 +0000</pubDate>
</item>
<item>
<title>Answered: What is the purpose of RequestDispatcher Interface?</title>
<link>https://madanswer.com/72183/what-is-the-purpose-of-requestdispatcher-interface?show=72184#a72184</link>
<description>The RequestDispacher interface provides the facility of dispatching the request to another resource it may be html, servlet or jsp. This interceptor can also be used to include the content of antoher resource.</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72183/what-is-the-purpose-of-requestdispatcher-interface?show=72184#a72184</guid>
<pubDate>Tue, 11 Apr 2023 19:44:49 +0000</pubDate>
</item>
<item>
<title>Answered: What is servlet collaboration?</title>
<link>https://madanswer.com/72181/what-is-servlet-collaboration?show=72182#a72182</link>
<description>When one servlet communicates to another servlet, it is known as servlet collaboration. There are many ways of servlet collaboration:&lt;br /&gt;
&lt;br /&gt;
RequestDispacher interface&lt;br /&gt;
&lt;br /&gt;
sendRedirect() method etc.</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72181/what-is-servlet-collaboration?show=72182#a72182</guid>
<pubDate>Tue, 11 Apr 2023 19:44:21 +0000</pubDate>
</item>
<item>
<title>Answered: What is difference between GenericServlet and HttpServlet?</title>
<link>https://madanswer.com/72179/what-is-difference-between-genericservlet-and-httpservlet?show=72180#a72180</link>
<description>&lt;p&gt;The GenericServlet is protocol independent whereas HttpServlet is HTTP protocol specific. HttpServlet provides additional functionalities such as state management etc.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72179/what-is-difference-between-genericservlet-and-httpservlet?show=72180#a72180</guid>
<pubDate>Tue, 11 Apr 2023 19:43:58 +0000</pubDate>
</item>
<item>
<title>Answered: What is difference between PrintWriter and ServletOutputStream?</title>
<link>https://madanswer.com/72177/what-is-difference-between-printwriter-and-servletoutputstream?show=72178#a72178</link>
<description>&lt;p&gt;PrintWriter is a character-stream class where as ServletOutputStream is a byte-stream class. The PrintWriter class can be used to write only character-based information whereas ServletOutputStream class can be used to write primitive values as well as character-based information.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72177/what-is-difference-between-printwriter-and-servletoutputstream?show=72178#a72178</guid>
<pubDate>Tue, 11 Apr 2023 19:43:36 +0000</pubDate>
</item>
<item>
<title>Answered: When servlet object is created?</title>
<link>https://madanswer.com/72173/when-servlet-object-is-created?show=72174#a72174</link>
<description>At the time of first request.</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72173/when-servlet-object-is-created?show=72174#a72174</guid>
<pubDate>Tue, 11 Apr 2023 19:42:24 +0000</pubDate>
</item>
<item>
<title>Answered: Who is responsible to create the object of servlet?</title>
<link>https://madanswer.com/72171/who-is-responsible-to-create-the-object-of-servlet?show=72172#a72172</link>
<description>The web container or servlet container.</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72171/who-is-responsible-to-create-the-object-of-servlet?show=72172#a72172</guid>
<pubDate>Tue, 11 Apr 2023 19:41:57 +0000</pubDate>
</item>
<item>
<title>Answered: What are the life-cycle methods for a servlet?</title>
<link>https://madanswer.com/72169/what-are-the-life-cycle-methods-for-a-servlet?show=72170#a72170</link>
<description>&lt;p&gt;&lt;/p&gt;&lt;p&gt;Below&amp;nbsp;&lt;span style=&quot;color:#000000; font-family:Arial,sans-serif; font-size:18px&quot;&gt;are the life-cycle methods for a servlet&lt;/span&gt;&lt;/p&gt;&lt;table border=&quot;1&quot; style=&quot;border-collapse:collapse; border-spacing:0px; border:1px solid #c7ccbe; font-family:inter-regular,system-ui,-apple-system,BlinkMacSystemFont,&amp;quot;Segoe UI&amp;quot;,Roboto,&amp;quot;Helvetica Neue&amp;quot;,Helvetica,Arial,sans-serif; width:739.938px; border-spacing: 0px;&quot; class=&quot;alt&quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;background-color:#eff1eb&quot;&gt;&lt;th style=&quot;color: rgb(0, 0, 0); background-color: rgb(199, 204, 190); font-size: 17px; font-family: &amp;quot;times new roman&amp;quot;; padding: 12px; vertical-align: top; text-align: left;&quot;&gt;Method&lt;/th&gt;&lt;th style=&quot;color: rgb(0, 0, 0); background-color: rgb(199, 204, 190); font-size: 17px; font-family: &amp;quot;times new roman&amp;quot;; padding: 12px; vertical-align: top; text-align: left;&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-color:#c7ccbe; border-style:solid; border-width:1px; line-height:1.7; margin-left:0px; padding:8px; text-align:justify; vertical-align:top&quot;&gt;public void init(ServletConfig config)&lt;/td&gt;&lt;td style=&quot;border-color:#c7ccbe; border-style:solid; border-width:1px; line-height:1.7; margin-left:0px; padding:8px; text-align:justify; vertical-align:top&quot;&gt;It is invoked only once when first request comes for the servlet. It is used to initialize the servlet.&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;background-color:#eff1eb&quot;&gt;&lt;td style=&quot;border-color:#c7ccbe; border-style:solid; border-width:1px; line-height:1.7; margin-left:0px; padding:8px; text-align:justify; vertical-align:top&quot;&gt;public void service(ServletRequest request,ServletResponse)throws ServletException,IOException&lt;/td&gt;&lt;td style=&quot;border-color:#c7ccbe; border-style:solid; border-width:1px; line-height:1.7; margin-left:0px; padding:8px; text-align:justify; vertical-align:top&quot;&gt;It is invoked at each request.The service() method is used to service the request.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-color:#c7ccbe; border-style:solid; border-width:1px; line-height:1.7; margin-left:0px; padding:8px; text-align:justify; vertical-align:top&quot;&gt;public void destroy()&lt;/td&gt;&lt;td style=&quot;border-color:#c7ccbe; border-style:solid; border-width:1px; line-height:1.7; margin-left:0px; padding:8px; text-align:justify; vertical-align:top&quot;&gt;It is invoked only once when servlet is unloaded.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72169/what-are-the-life-cycle-methods-for-a-servlet?show=72170#a72170</guid>
<pubDate>Tue, 11 Apr 2023 19:41:35 +0000</pubDate>
</item>
<item>
<title>Answered: What is the life-cycle of a servlet?</title>
<link>https://madanswer.com/72167/what-is-the-life-cycle-of-a-servlet?show=72168#a72168</link>
<description>&lt;p&gt;life-cycle of a servlet :&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Servlet is loaded&lt;/li&gt;&lt;li&gt;servlet is instantiated&lt;/li&gt;&lt;li&gt;servlet is initialized&lt;/li&gt;&lt;li&gt;service the request&lt;/li&gt;&lt;li&gt;servlet is destroyed&lt;/li&gt;&lt;/ol&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72167/what-is-the-life-cycle-of-a-servlet?show=72168#a72168</guid>
<pubDate>Tue, 11 Apr 2023 19:40:47 +0000</pubDate>
</item>
<item>
<title>Answered: How many objects of a servlet is created?</title>
<link>https://madanswer.com/72165/how-many-objects-of-a-servlet-is-created?show=72166#a72166</link>
<description>&lt;p&gt;Only one object at the time of first request by servlet or web container.&lt;/p&gt;&lt;div&gt;&lt;/div&gt;</description>
<category>Servlet</category>
<guid isPermaLink="true">https://madanswer.com/72165/how-many-objects-of-a-servlet-is-created?show=72166#a72166</guid>
<pubDate>Tue, 11 Apr 2023 19:40:04 +0000</pubDate>
</item>
</channel>
</rss>