您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
请求行:
package com.my.servlet; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.net.URL; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class ContextServlet */ @WebServlet("/ContextServlet") public class ContextServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public ContextServlet() { super(); } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String method = request.getMethod();//获取使用的HTTP方法; String URi = request.getRequestURI();//获取请求中的资源名部分 String protocol = request.getProtocol();//获得协议号 String queryString = request.getQueryString();//获得查询语句 String servletPath = request.getServletPath(); String contextpath = request.getContextPath();//获得web应用路径 PrintWriter out = response.getWriter(); out.println("<p>请求使用的http方法"+method+"</p>"); out.println("<p>请求行中的资源名部分"+URi+"</p>"); out.println("<p>请求使用的协议"+protocol+"</p>"); out.println("<p>查询字符串"+queryString+"</p>"); out.println("<p>Servlet所映射的路径"+servletPath+"</p>"); out.println("<p>请求资源所属的WEb应用路径"+contextpath+"</p>"); out.flush(); out.close(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。