java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
- All Implemented Interfaces:
- Serializable, Servlet, ServletConfig
- See Also:
- Top Examples, Source Code
protected void doDelete(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- See Also:
ServletResponse.setContentType(java.lang.String)
, ServletResponse.setContentLength(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[142]Hello World servlet
By Anonymous on 2004/04/15 12:25:55 Rate
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet ( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
PrintWriter out = response.getWriter ( ) ;
out.println ( "Hello World" ) ;
}
}
protected void doHead(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void doOptions(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void doPost(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- See Also:
ServletResponse.setContentType(java.lang.String)
, ServletOutputStream
, ServletResponse.setContentLength(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void doPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void doTrace(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected long getLastModified(HttpServletRequest req)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public HttpServlet()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[176]A servlet that prints out request attributes
By Edward Sumerfield on 2003/03/14 08:52:59 Rate
package mypackage;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import conceptdefgen.util.Url;
public class MyServlet extends HttpServlet
{
public String getServletInfo ( )
{
return "MyServLet";
}
public void init ( ServletConfig config ) throws ServletException
{
super.init ( config ) ;
}
public void destroy ( )
{
}
protected void processRequest (
HttpServletRequest request,
HttpServletResponse response )
throws ServletException, java.io.IOException
{
// Get the output stream to write the response to.
OutputStream l_out = response.getOutputStream ( ) ;
PrintStream l_print = new PrintStream ( l_out ) ;
// Default all responses to html.
response.setContentType ( "text/html" ) ;
l_println ( " < html > " ) ;
l_println ( " < p > This is MyServlet < /p > " ) ;
l_println ( "URL details: < br/ > " ) ;
l_println ( request.getProtocol ( ) ) ;
l_println ( request.getServerName ( ) ) ;
l_println ( request.getServerPort ( ) ) ;
l_println ( request.getRequestURI ( ) ) ;
l_println ( request.getQueryString ( ) ) ;
l_println ( " < /html > " ) ;
// Flush and close the output stream
l_print.flush ( ) ;
l_print.close ( ) ;
}
protected void doGet (
HttpServletRequest request,
HttpServletResponse response )
throws ServletException, java.io.IOException
{
processRequest ( request, response ) ;
}
protected void doPost (
HttpServletRequest request,
HttpServletResponse response )
throws ServletException, java.io.IOException
{
processRequest ( request, response ) ;
}
}
protected void service(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- See Also:
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void service(ServletRequest req,
ServletResponse res)
throws ServletException,
IOException
- See Also:
-
HttpServletResponse
, HttpServletRequest
, GenericServlet, Servlet
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples