📄 helloservlet.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -