helloservlet.java
来自「J2EE开发与Weblogic一书中的源代码」· Java 代码 · 共 38 行
JAVA
38 行
package com.learnweblogic.examples.ch2;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
// Next, we will define our class:
public class HelloServlet extends HttpServlet {
// And finally, we will define our two methods:
// The Service Method to Handle HTTP Requests and Responses
public void service(HttpServletRequest requ,
HttpServletResponse resp)
throws IOException
{
// Now Set the Response Content Type
resp.setContentType("text/html");
// Now obtain a PrintWriter stream to write to.
PrintWriter out = resp.getWriter();
// Now Print Out Our Text
out.println("<html><head><title>" +
"Hello World!</title></head><body>" +
"Hello World!</h1></body></html>");
}
// The INIT Method Called by the Container Before the
// First Call to the Service Method.
public void init(ServletConfig config)
throws ServletException
{
// Must call super.init to parse init arguments
super.init(config);
// ...
}
} // HelloServlet
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?