Q1. What is the servlet?
Ans: Servlet is simple java class and it extending the
functionality of a web server and that are execute on the server side.
It requires a servlet container to run .
Q2. Why we used servlet?
Ans:To handle client request and response(mostly in the from
of HTTP/HTTPS request)or forward the request to another servlet or jsp
Q3. Explain Servlet Life cycle?
Ans: servlet life cycle controller by Servlet Container and
container performs the following steps.
If an instance of the servlet does not exist ,web container
Step 1 :load the servlet class.
Step 2 :Creates an instance of the servlet class and
initialize the servlet instance by calling the init() method.
Step 3 :Invokes the serivce method, passing a request and
response object.
to the service() method.
Step 4:If the container needs to remove the servlet,it
finilizes the servlet by calling the servlet's destory method.
Q4. What are scope object available?
Ans:Enable sharing information between we application via
attributes mentioned in the Scope objectAttributs mentained in scope Object are
access with setAttributs and getAttribute();
Q5. JSP implicity Object?
Ans: Request
Responce
PageContext
Session
applicaiton
Out
Config
page
exception
Q6. JSP Scope Object?
Ans:Page Scope :a Single page
Request Scope:Pages Processing the same
request
Session Scope:Pages processing the request
that are in same session
Application Scop : all pages in an
application
Q 7 .What is Request Dispatcher?
When building a web application ,you want to forward processing to another component. or if you want to include the
processing of another component in the current response.
In Servlet API,we need to use a Request Dispatcher.This is retrieve from the ServletContext.
public RequestDispatcher
getRequestDispatcher(String path)
The RequestDispatcher is create base on the path used to to
obtain it(You must begin with a "/")
public void forwared(ServletRequest
request,ServletResponSe response)
public void include(ServletRequest request
,ServletResponce response)
Q8. What is difference between SendRediresct and Forward?
Ans: When we used forward method request is transfer to other
resource within the same server for further processing.
and in case sendRequest request is transfer is transfer to
another resource to differance domain or different server for further processing.
Next difference is visually we are not able to see the
forwarded address,it is transparent and in sendRedirect we are see the new
redirected address it's not transparent
No comments:
Post a Comment