OverviewFor brevity and clarity, many of our code samples contain code snippets for Java Extensions rather than entire Java Extension classes. A Java Extension is a class derived from the A Java Extension source file will contain a full declaration for a Java Extension class; for example: Generic Servlets
import java.io.IOException;
import javax.servlet.GenericServlet;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class Example extends GenericServlet {
private static final long serialVersionUID = 1L;
public void service( ServletRequest req, ServletResponse res )
throws IOException
{
// Do stuff...
}
}
HTTP Servlets
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Example extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException
{
// Do stuff...
}
public void doPost( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException
{
// Do stuff...
}
}
Often, an HTTP servlet will handle GETs and POSTs in an identical fashion, so the
public void doPost( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException
{
doGet( req, res );
}
Code SamplesMany of the code samples you will see here just provide the implementations for the Most IDEs will help you insert the correct imports - Ctrl-Shift-O in Eclipse will do the trick for example. References
Owen Garrett
[Zeus Dev Team] 01 July 2008
|
Recent Articles
Other Resources
|


