httpservlet httpservlet
class httpservlet methods httpservlet java httpservlet api genericservlet vs
httpservlet httpservlet jar httpservlet response genericservlet and httpservlet
httpservlet request generic servlet servlet interface
we are extending generic servlet or httpservlet class is nothing but we are indirectly implementing servlet interface.
Servlet Interface :(javax.servlet.*)
Different
ways of creating servlet:
We can create a servlet class in the
following three ways.
1) By implementing our class from Servlet interface.
2) By extending our class from Generic Servlet.
3) By extending our class from Http Servlet.
we are extending generic servlet or httpservlet class is nothing but we are indirectly implementing servlet interface.
Servlet Interface :(javax.servlet.*)
- Servlet Interface is Root of
Servlet Programming
- Servlet Interface Contains
Follwing methods
1. init(parameters)
2. service(ServletRequest req,ServletResponse res)
3. destroy()
4. getServletConfig()
5. getServletInfo()
Among all
these above five methods first 3 methods are called life cycle of servlet
Generic
Servlet :(javax.Servlet.Http.*)
In Generic Serlvet Class
Four methods of servlet interface are implemented and one method is
not implemented in generic
servlet class.
Syntax of Generic Servlet:
import javax.servlet.*;
public abstract class genericServlet implements
Servlet,ServletConfig,Serializable
{
public void init()
{
-------------
-------------
}
public void destroy()
{
-------------
-------------
}
service(req,res);
public void getServletInfo()
{
----------------
----------------
}
}
HttpServlet (javax.Servlet.Http.*) :
HttpServlet is Derived or Bottom Class of the Servlet Hierarchy. HttpServlet is
contains all features that are in generic servlet class that are inherited to
HttpServlet Class extra to that it contains Non Life cycle Service() Method and
7 DoXXX() methods(ie. doget(),dopost()..............) .
Internal
Flow Of HttpServlet:
public HttpServlet extends GenricServlet
{
public void init()
{
}
public void init(ServletConfig sc)
{
-------------------
------------
service(req,res);
}
public void service(ServletRequest req,ServletResponse res)
{
//conversion ServletRequest And ServletResponse to HttpServletRequest And //HttpServletResponse
service(httpreq,httpres);
}
public void service(HttpServletRequest req,HttpServletResponse
res)
{
//-------------
//-------------
}
public void destroy()
{
//---------------------
}
}
No comments:
Post a Comment