GenericServlet

Advertisements

Prev Tutorial Next Tutorial

GenericServlet

GenericServlet class Implements Servlet, ServletConfig and Serializable Interfaces. It provides the implementation of all the methods of these Interfaces except the service method. GenericServlet class can handle any type of request so it is protocol Independent. You may create a generic Servlet by inheriting the GenericServlet class and providing the Implementation of the service method.

This is a implemented abstract class for Servlet Interface, have the implementation for all methods of Servlet interface except service method.

Methods of GenericServlet

All methos of Servlet Interface are inherit in GenericServlet class because it Implements Servlet Interface. Following methods are used in GenericServlet.

Example of Servlet by inheriting the GenericServlet class

Example

import java.io.*;
import javax.servlet.*;
public class GenericServletDemo extends GenericServlet
{
public void service(ServletRequest req,ServletResponse resp)
throws IOException,ServletException
{
res.setContentType("text/html");
PrintWriter out=resp.getWriter();
out.print("<html><body>");
out.print("<b>Example of GenericServlet</b>");
out.print("</body></html>");
}
}

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements