只要你有一台电脑或者手机,都能关注图老师为大家精心推荐的Java Servlet 编程及应用之二,手机电脑控们准备好了吗?一起看过来吧!
【 tulaoshi.com - 编程语言 】
进行Servlet开发所需要的基本环境是JSDK以及一个支持Servlet的Web服务器
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/) 编写Servlet所需要的开发环境import java.io.*;
import java.servlet.*;
import javax.servlet.*;
public class RequestInfoExample extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Request Information Example</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>Request Information Example</h3>");
out.println("Method: " + request.getMethod());
out.println("Request URI: " + request.getRequestURI());
out.println("Protocol: " + request.getProtocol());
out.println("PathInfo: " + request.getPathInfo());
out.println("Remote Address: " + request.getRemoteAddr());
out.println("</body>");
out.println("</html>");
}
public void doPost(HttpServletRequest request, HttpServletResponse res)
throws IOException, ServletException
{
doGet(request, response);
}
}
------------------------------------------------
Request Information Example
Method: GET
Request URI: /examples/servlet/RequestInfoExample
Protocol: HTTP/1.1
Path Info: null
Remote Address: 127.0.0.1
--------------------------------------------------
来源:http://www.tulaoshi.com/n/20160219/1599378.html
看过《Java Servlet 编程及应用之二》的人还看了以下文章 更多>>