20160324 javaweb 之request

package com.dzq.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/CustomInfoServlet")
public class CustomInfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String url=request.getRequestURL().toString();
		System.out.println(url);
		String uri=request.getRequestURI().toString();
		System.out.println(uri);
		String qStr=request.getQueryString();
		System.out.println(qStr);
		String ip=request.getRemoteAddr();
		System.out.println(ip);
		String method =request.getMethod();
		System.out.println(method);
		String name=request.getContextPath();
		System.out.println(name);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}

  

 

  

posted @ 2016-03-24 22:24 破玉 阅读(...) 评论(...) 编辑 收藏