| Back to Questions Page |
| |
| Question |
Hi friends, am newbie to servlet. My interviewer asked why
used servlet in your application.
i used servlet for controller logic and business logic .
is it correct ? |
Rank |
Answer Posted By |
|
Question Submitted By :: Rajendra007 |
| This Interview Question Asked @ TCS |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | yes correct.And the answer should also include that because
servlet has some methods that are inherited from super class
like...init,destroy and many more that are used to handle
the request.  |
| Jitendra |
| |
| |
| Question |
can we use more than one controller in web application |
Rank |
Answer Posted By |
|
Question Submitted By :: Rajendra007 |
| This Interview Question Asked @ IBM |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | We can have multiple controllers but if it is a struts
framework then it voilates MVC design since we cannot have
more than one controller in MVC  |
| Kishore |
| |
| |
| Question |
Hi Frieds, I am new to servlet why to use servlet in
webapplication. what i know is " use servlet as a
controller in mvc and to implemnent business logic . is it
correct ? One more thing reason for implementing business
logic with servlets , why not jsp. |
Rank |
Answer Posted By |
|
Question Submitted By :: Rajendra007 |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Servlet is a server side technology,for developing
serverside application(web applications).
In ModelI we use Servlet and Jsp's only.jsp used for
Presentation logic and Servlet used for Business logic & as
Controller.
Why because- 1.for communating with DataBase
2.for container(server)recognise java code.  |
| Syed |
| |
| |
|
|
| |
| Answer | To build a dynamic web page servlets are used.  |
| Ashok Kannan |
| |
| |
| Answer | yes Boss we build....refer in ur old frd GOOGLE  |
| Syed |
| |
| |
| Question |
why business logic written using servlets not in jsp. Jsp
used for presentation purpose. serlvet used for coding
business logic and controller logic. Reason for using
servlets in business logic. |
Rank |
Answer Posted By |
|
Question Submitted By :: Rajendra007 |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | In servlets we have resource for developing the business
logic but Jsp have the tags for present the output clerly.  |
| Rajesh |
| |
| |
| Answer | Its for reusability purpose.jsp should be only used for
presentation purpose and our html designer,who later design
the page is not aware of java coding will not be comfortable.
and writing all buiseness logic in servlet lets the code
reusable.and for writing buiseness logic in jsp page there
are some other way like using scriplets.so why do the job
with less profit and extra work.  |
| Jitendra |
| |
| |
| Question |
what is the control flow in servlet when we send a request? |
Rank |
Answer Posted By |
|
Question Submitted By :: Dipak.cvrca |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | -->first request comes from client browser to server
(container)which takes the control to the web.xml file.
-->in xml file servlet file(.class) will be searched
according to the information about the url pattern given
in the address,then coresponding class file is loaded to
the container(loading) by the method
java.lang.class.forName().newInstance.
-->now container call the init(servletConfig) method to add
necessary headers in the servlet,such as Config,context
session,request and many more.
-->now control pass to the service()of the HttpServlet(if
you have extended this class) and the type of method
(get/post) is checked and accordingly the control will
pass to the implemented doGet() or doPost() of the your
class(by the dynamic method dispatch)
-->after service the container will call the destroy() of
Servlet class.
i hope this answer will satishfy you,thank
you,Dipu(Deepak ku. jenamani)  |
| Dipak.cvrca |
| |
| |
| Answer | when we are requesting a particular resource in the
server,the comiled class will be loaded into the container
calls the no-arg constructor and init() then the container
will create request,response objects and pass it to the
corresponding doXXX() method based on the http method of the
form,allocates a thread and do the business logic and send
the response back to the client by sending the thread to a
connection pool and destroying the request and response objects  |
| Ravikiran |
| |
| |
| Answer | when we are requesting a particular resource in the
server,the comiled class will be loaded into the container
calls the no-arg constructor and init() then the container
will create request,response objects and pass it to the
corresponding doXXX() method based on the http method of the
form,allocates a thread and do the business logic and send
the response back to the client by sending the thread to a
connection pool and destroying the request and response objects  |
| Ravikiran |
| |
| |
| Question |
describe all about advanced java with presentation |
Rank |
Answer Posted By |
|
Question Submitted By :: Sapna1999_123 |
| This Interview Question Asked @ Sun-Microsystems |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | advanced java is the one which deals with web application
components...servlets will deal with the business logic by
putting the html code inside java,jsp concentrates on
presentation logic by putting the java code inside html..
The EJB will act on the distribute applications which run on
the same JVM or in a remote location  |
| Ravikiran |
| |
| |
| Answer | advanced java is the one which deals with web application
components...servlets will deal with the business logic by
putting the html code inside java,jsp concentrates on
presentation logic by putting the java code inside html..
The EJB will act on the distribute applications which run on
the same JVM or in a remote location  |
| Ravikiran |
| |
| |
| Question |
Can we call destroy() method inside the init() method? What
happens when we do so? |
Rank |
Answer Posted By |
|
Question Submitted By :: Manub22 |
| This Interview Question Asked @ Ericsson |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Yes you can call init method in destroy.
public void destroy(){
try {
init();
}
catch(Exception e){
}
}  |
| Sunny |
| |
| |
| Answer | if suppose we take the servlet programming side then
whenever u type the URL first web browser call the service
method then create the servlet object then call the
init()method whenever we call the init method start the
proceesses of the particular object operation suppose we
call the destroy()method before completion of the particular
object operation servelet object is removed then when we r
call the service method then create the servelet object
 |
| Poorna Chandar Rao.yerrabothu |
| |
| |
| Answer | In the Servlet programming context, the destroy() method
can never be called by your code and is called by the
servlet container  |
| Mani |
| |
| |
| Answer | In the servlet life cycle First our request calls to the
init()method,Inside it will doing some operations related
to the objects after that it will cal the destory() method
The destory()removes the servlet object,before calling to
service() method.  |
| Srilatha |
| |
| |
| Answer | Yes you can call a destroy() method in init() method, but
remember destroy() method will behave like normal method
but not as life-cycle method.  |
| Ashwin Kumar J |
| |
| |
| Answer | a call to the destroy method will happen and the resources
will be released and the flow will continue as it is and
will throw an exception if the released resource is used
indie the service method call.  |
| Ravikiran |
| |
| |
| Answer | a call to the destroy method will happen and the resources
will be released and the flow will continue as it is and
will throw an exception if the released resource is used
indie the service method call.  |
| Ravikiran |
| |
| |
| Answer | This action does not disturb the normal life cycle flow of the servlet. The servlet will work normal. You may test the below code.
/**
* @author Suraj
*
*/
public class TestServlet extends HttpServlet {
public void init(ServletConfig config)throws ServletException{
super.init(config);
destroy();
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("I am test servlet.");
}
}
Web.xml
--------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Servlet</display-name>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.esspl.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
------------------------------------
Test URL: http://<HOST>:<PORT>/<Context>/TestServlet.do  |
| Suraj Kumar |
| |
| |
| Question |
i am bca student,give me suggest for bright future |
Rank |
Answer Posted By |
|
Question Submitted By :: Reeta Shukla |
| This Interview Question Asked @ BSNL , Future Consideration |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | do some business  |
| Sathish |
| |
| |
| Answer | join eikon technologies.............
contact kavitha....
+919449026273  |
| Hara Hara |
| |
| |
| Answer | U better do engineering....then u Ve a brt ftr....  |
| Ravichand |
| |
| |
| Answer | first improve vocabulary,then learn what are your
strengths,choose a course to improve them further and pursue
a career in that field.  |
| Amit |
| |
| |
| Answer | your bright future depends on your valuable right decision
taking at right time. If you are interested in business and
non IT, then go for MBA. If you are intersted in Computers
(IT) choose MCA in good university. Mainly i am emphasising
on your interest bcoz, if we do the work what ever we like,
in which we will get success and we will get unique ness in
that work. that means we will show interest, due to that we
will get good reputation.
So think once select either of one , show your
efforts, I am sure that you will get success. Basically i
did BCA, after that i Did MCA. Now i settled as Software
Engineer.Basically iam commerce student(CEC) but i have so
much interest on computers so that i did BCA and then MCA.
Now i got success in my life.
As a person we can give suggestions, select the right
decision, because you are the decision maker for your own
life.  |
| Swapna |
| |
| |
| Answer | i am bca student
please guide me in time management of study and my aim will
be Big IT engineer so planing is study time management.
please help me
Mr. YOGI PATEL  |
| Yogin Patel |
| |
| |
| Answer | Do Mtech(IIIT).  |
| Roja |
| |
| |
| Answer | if you are able to remeber lots of information do java
otherwise do dot net (or) php  |
| Ravikiran |
| |
| |
| Answer | if you are able to remeber lots of information do java
otherwise do dot net (or) php  |
| Ravikiran |
| |
| |
| Answer | in my opinion firstly you concentrate your basic study
imean that you learn your progamming languages like "c" if
you have depth knowedge than you got success in yur life
after c you learn your other progaamming languages in depth
like c++ aspnet and java. because in this time many
software companies offered to the fresher student  |
| Abhishek Agrahari |
| |
| |
| Question |
can u give some realtime example in ploymorphism? and
inheritance? |
Rank |
Answer Posted By |
|
Question Submitted By :: Vikneswarank |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Inheritance is a concept which involves the concept of re
usability Ex:Bank Accounts-->SB Account,RD Account,CD Account
Polymorphism concept of one existing in many forms
Ex:In Graphical User interfaces,AWT  |
| Walkinglegendteja |
| |
| |
| Answer | inheritance is hierarchy of class,that is one class derived
from another class
example:
grant father
--father
--son
polymorphism is the ability to take more than one form
example:
compile time polymorphism
--method overloading
people can act many role in the world
home:father
company:employee
run time polymorphism
--method overriding
dog is a class
It contains smile method  |
| Suresh [Jadian] |
| |
| |
| Answer | Polymorphism applies to Overriding
Inheritance applies to Reusability of code defined earlier in one Class and later on used by Other Classes..  |
| Nazneen [Jadian] |
| |
| |
| Answer | Human being life is the best example for ploymorphism bcoz
Let one take example
im a son of my parents and also brother of my sister and
the employee of one company ...
Im playing the many role here.
Same example for inheritance also bcoz i have inherited my
father property.  |
| Mani [Jadian] |
| |
| |
| Answer | polymorphism: Polymorphism one form existing many forms is
called polymorphism.its used for over ridding.
EX:Man
Because A Man go to office he is an Employee.
A Man go to movie he is an auditor.
A man walk with his lover she's boy friend
inheritance is hierarchy of class,that is one class derived
from another class
EX:
grant father
--father
--son  |
| Srinu [Jadian] |
| |
| |
| Answer | abstract class Person
{
public String sname(){}
Address ad;
}
class Patient extends Person
{
}
class Employee extends Person
{
}
Here in the above example Person is a class acting two ways
one Patient details info and Employee details. We are
achieving this extends Person i.e inheritence.Inheritence
provides code reusability,extensibility  |
| Abdulrazak [Jadian] |
| |
| |
| Question |
when will cookie information destroy? |
Rank |
Answer Posted By |
|
Question Submitted By :: Vikneswarank |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | cookie is small amount of data and it's store on the client
machine that is your browser machine
..Developer to create cookie and set the life time of cookie
on our web application
example
cookie.setMaxAge(1000);
the cookie available in 1000ms  |
| Suresh |
| |
| |
| Answer | cookie is a"small amount of data" that is set by the server
on the client.
we have setmaxAge() for destroy cookie.
1.cookie.setMaxAge(100)-->100 sec
If we set the max age of a cookie to 100 sec,the browser
holds the cookie for 100 sec even if we close the browser.
2.If we set max age value to negative value the browser hold
the cookie till we close the browser.
3.If we use setMaxAge(0) the browser will arase the cookie.  |
| Balakrishna [Jadian] |
| |
| |
| Answer | when we disable the cookies inside the client browser or if
the cookie age is finished which is set as
cookie.setMaxAge(mins*secs);  |
| Ravikiran [Jadian] |
| |
| |
| Answer | when we disable the cookies inside the client browser or if
the cookie age is finished which is set as
cookie.setMaxAge(mins*secs);  |
| Ravikiran [Jadian] |
| |
| |
| Question |
What is forward() and include() of servlets
RequestDispatcher interface? |
Rank |
Answer Posted By |
|
Question Submitted By :: Gangadhar_interview |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Forward():By using forward() method of RequestDispatcher ,ew
can forward a request to a another resource(i.e
servlets,jsp,html....),at finally we can see only called
resource output(i.e second resource output )
For exm. we have two servlets,(servlet1 and servlet2) we are
forwarding request from servlet1 to servlet2, in this case
we can see only servlet2 output.
include():By using include() method of RequestDispatcher we
can forward a request from servlet12 to servlet2 ,in this
case we can see both outputs(i.e servlet1 and servlet2).
in both case single request and single response.  |
| Katamraju |
| |
| |
| Answer | forward() is used to just forward the request and response
object...
include() is used to pass the values and request and
response object,one servlet to another servlet  |
| Suresh |
| |
| |
| Answer | Forward():
In ServletRequestDispatcher ,By using forward() method,we
can forward a request to a another resource(i.e
servlets,jsp,html....),at finally we can see only called
resource output(i.e second resource output,i.e response)
For exm. we have two servlets,(servlet1 and servlet2) we are
forwarding request from servlet1 to servlet2, in this case
we can see only servlet2 output(i.e response for the
request).
in forward()it will take only servlet1 output.
(ex: in servlet we a\are having some name like srinu with
background color blue, it will take only the name not the
color)
include():
By using include() method of RequestDispatcher we
can forward a request from servlet1 to servlet2 ,in this
case we can see both outputs(i.e servlet1 and servlet2).
in include()it will include the servlet1 page and
forwarding to the servlet2)
in this case we can see both servlet1& servlet2 as the
part of response.  |
| Srilatha |
| |
| |
| Answer | forward will make the flow into a different page,where as
include mechanism will include the page to the current
response and continues the flow.
Note:the forward and include should be called before the
response is committed for example before the call to flush()
or flushBuffer() or the write method in the response stream  |
| Ravikiran |
| |
| |
| Answer | forward will make the flow into a different page,where as
include mechanism will include the page to the current
response and continues the flow.
Note:the forward and include should be called before the
response is committed for example before the call to flush()
or flushBuffer() or the write method in the response stream  |
| Ravikiran |
| |
| |
|
| |
|
Back to Questions Page |