Tuesday, May 5, 2015

Can we call destroy() method on servlets from service method?

Question:Can we call destroy() method on servlets from service method??

Answer: <P><FONT face="Courier New">destroy() is a servlet life-cycle method called by servlet container to kill the instance of the servlet. </FONT></P><P><FONT face="Courier New">The answer to your question is "Yes". You can call destroy() from within the service(). It will do whatever logic you have in destroy()<SCRIPT><!--D(["mb","<br>rn(cleanup, remove attributes, etc.) but it won&#39;t "unload" the servlet <br>rninstance itself. That can only be done by the container<br>rn<br>rn3)Yes u can use Vector in a servlet.<br>rn<br>rn4)Parsers are programs which take any xml document as input and can <br>rnread it and give you the values inside the elements  and the <br>rnattributes.Then you can use them any way you want.<br>rn          We can use them in our application when ever we want to <br>rnread an XML and get the information/data out of it.<br>rn<br>rn5)Other Immutable objects are:- anything which is declared final<br>rn(class,method or variable) are immutable. One should try to make a <br>rnclass immutable by completing creating an object when it&#39;s <br>rnconstructor is called rather than using empty constructors.For that <br>rnconstructors need to be written which take arguments and sets the <br>rnvalue there. Since if an object is immutable then:-<br>rn-are simple to construct, test, and use <br>rn-are automatically thread-safe and have no synchronization issues <br>rn-do not need a copy constructor <br>rn-do not need an implementation of clone <br>rn-do not need to be copied defensively when used as a field <br>rn-make good Map keys and Set elements (these objects must not <br>rnchange    state while in the collection) <br>rn-the class invariant is established once upon construction, and never <br>rnneeds to be checked again <br>rn<br>rn<br>rnrest i will ans later.  Huh!!!!!!   :-))<br>rn                  <br>rn<br>rn&gt; &gt; &gt; &gt; &gt; &gt; &gt; mekala swapna &lt;mekala_001@y...&gt; wrote:1.<br>rn&gt; &gt; &gt; &gt; &gt; what<br>rn&gt; &gt; &gt; &gt; &gt; &gt; is servlet context and<br>rn&gt; &gt; &gt; &gt; &gt; &gt; &gt; what it takes actually<br>rn&gt; &gt; &gt; &gt; &gt; &gt; &gt; as parameters?<br>rn&gt; &gt; &gt; &gt; &gt; &gt; &gt; 2. can we call destroy() method on servlets<br>rn&gt; &gt; &gt; &gt; from<br>rn&gt; &gt; &gt; &gt; &gt; &gt; &gt; service method?<br>rn&gt; &gt; &gt; &gt; &gt; &gt; &gt; 3. is there any difficulty of using the vector",1]);//--></SCRIPT> (cleanup, remove attributes, etc.) but it won&#39;t "unload" the servlet instance itself. That can only be done by the container</FONT><BR></P>

Tags:Interview Questions, J2EE, Servlets,

Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.



Sponsor Advertisement



Customer Relationship Management Software

Customer Resource Management Software

CRM software is designed to help businesses in manageing their customer data and customer interaction, access business information, automate sales, marketing and customer support and also manage employee, vendor and partner relationships. ...

No comments:

Post a Comment