|
|||||
|
Every functional web servlet extends the HttpServlet base class. The simplest servlet responds to a request by printing some text. Before printing text, the servlet sets the response mime-type to text/html so the browser knows what to do with it. The code looks as follows: import javax.servlet.*;
import javax.servlet.http.*;
// MyServlet.java
public class MyServlet extends HttpServlet
{
public void doGet ( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException {
res.setContentType( "text/html");
PrintWriter out = res.getWriter();
out.println( "<html><body>" );
out.println( "Hello there!" );
out.close();
}
}
Compiled servlet class files should be placed under the WEB-INF/classes directory of the context. The default context created for all accounts is under the htdocs directory. Therefore, if you place the compiled class file for this servlet under your htdocs/WEB-INF/classes directory, it will be accessible with a URL of the form: http://yourdomain.com/servlet/MyServlet Note: MMA technical support staff cannot provide
troubleshooting of problems with third-party CGI scripts including but
not limited to: Perl scripts, C/C++ binaries, PHP or web/database integration
unless these services are specifically contracted. For these services,
please see our Quote Request Form. |
|||||
|
||||||
Copyright
© 1995-2000
Motivational Marketing Associates, LLC
All Rights Reserved.