request 参数 博客分类: Java语言_Utils HttpServletRequestrequest参数
程序员文章站
2024-03-18 16:44:16
...
package com.jie.request.servlet; import java.io.IOException; import java.io.InputStream; import java.security.Principal; import java.util.Collection; import java.util.Enumeration; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.StringTokenizer; import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.http.Part; import org.hibernate.classic.Session; import com.jie.request.db.DBhelper; import com.jie.request.entity.RequestInfoEntity; import com.jie.request.entity.Test; /** * Servlet implementation class RequestInfoServlet */ @WebServlet( description = "description", urlPatterns = { "/RequestInfoServlet" }, initParams = { @WebInitParam(name = "initName", value = "initValue", description = "initNameDesc") }) public class RequestInfoServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public RequestInfoServlet() { super(); System.out.println("RequestInfoServlet()"); } /** * @see Servlet#init(ServletConfig) */ public void init(ServletConfig config) throws ServletException { System.out.println("init()"); } /** * @see Servlet#destroy() */ public void destroy() { System.out.println("destroy()"); } /** * @see Servlet#getServletConfig() */ public ServletConfig getServletConfig() { System.out.println("getServletConfig()"); return null; } /** * @see Servlet#getServletInfo() */ public String getServletInfo() { System.out.println("getServletInfo()"); return null; } /** * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response) */ // protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // System.out.println("service()"); // } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doPost()"); request.setCharacterEncoding("utf-8"); RequestInfoEntity r = new RequestInfoEntity(); // request.authenticate(response);//证明是真实的、可靠的或有效的;鉴定,使生效 AsyncContext asyncContext = request.getAsyncContext();//需要在异步启动之后才能够访问,否则会报异常。 if(asyncContext!=null) { r.setAsyncContext(asyncContext.toString()); } System.out.println("asyncContext = " + asyncContext); Object attribute = request.getAttribute("name");//返回指定属性的对象,或者给定名称的属性存在空值。 if(attribute!=null) { r.setAttribute(attribute.toString()); } System.out.println("attribute = " + attribute); request.setAttribute("a", "a"); request.setAttribute("a", "b"); request.setAttribute("b", "b"); request.setAttribute("c", "c"); Enumeration<String> attributeNames = request.getAttributeNames();//返回一个包含提供给该请求的属性的名称枚举。 System.out.println("attributeNames = " + attributeNames); StringBuffer attributeNamesDB = new StringBuffer(); if(attributeNames.hasMoreElements()) { attributeNamesDB.append("["); while (attributeNames.hasMoreElements()) { String string = (String) attributeNames.nextElement(); System.out.print("string = " + string); attributeNamesDB.append(string); attributeNamesDB.append(","); Object value = request.getAttribute(string); System.out.println(" value = " + value); } attributeNamesDB.append("]"); attributeNamesDB.deleteCharAt(attributeNamesDB.length()-2); System.out.println("attributeNamesDB = " + attributeNamesDB.toString()); } else { attributeNamesDB.append("["); attributeNamesDB.append("]"); System.out.println("attributeNamesDB = " + attributeNamesDB.toString()); } r.setAttributeNames(attributeNamesDB.toString()); String authType = request.getAuthType();//返回用来保护servlet的认证方案的名称。 r.setAuthType(authType); System.out.println("authType = " + authType); String characterEncoding = request.getCharacterEncoding();//返回此请求的主体中使用的字符编码的名称。 r.setCharacterEncoding(characterEncoding); System.out.println("characterEncoding = " + characterEncoding); Class<? extends HttpServletRequest> class1 = request.getClass(); r.setClassName(class1.getName().toString()); System.out.println("class1 = " + class1.getName()); int contentLength = request.getContentLength();//返回请求体的长度,以字节为单位,并通过对输入流提供或-1,如果长度是不知道。 r.setContentLength(String.valueOf(contentLength)); System.out.println("contentLength = " + contentLength); String contentType = request.getContentType();// 如果返回的类型是不知道的MIME类型的请求的主体,或者null。 r.setContentType(contentType); System.out.println("contentType = " + contentType); String contextPath = request.getContextPath();//返回请求的URI,表示该请求的上下文的一部分。 r.setContextPath(contextPath); System.out.println("contextPath = " + contextPath); Cookie[] cookies = request.getCookies();//返回一个包含所有的Cookie对象的数组这个请求发送的客户端。 StringBuffer cookiesDB = new StringBuffer(); if(cookies != null && cookies.length >0) { cookiesDB.append("["); for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; //cookie 对象 Object clone = cookie.clone(); System.out.println("clone = " + clone); cookiesDB.append(clone); cookiesDB.append(","); String comment = cookie.getComment(); System.out.println("comment = " + comment); cookiesDB.append(comment); cookiesDB.append(","); String domain = cookie.getDomain(); System.out.println("domain = " + domain); cookiesDB.append(domain); cookiesDB.append(","); int maxAge = cookie.getMaxAge(); System.out.println("maxAge = " + maxAge); cookiesDB.append(maxAge); cookiesDB.append(","); String name = cookie.getName(); System.out.println("name = " + name); cookiesDB.append(name); cookiesDB.append(","); String path = cookie.getPath(); System.out.println("path = " + path); cookiesDB.append(path); cookiesDB.append(","); boolean secure = cookie.getSecure(); System.out.println("secure = " + secure); cookiesDB.append(secure); cookiesDB.append(","); String value = cookie.getValue(); System.out.println("value = " + value); cookiesDB.append(value); cookiesDB.append(","); int version = cookie.getVersion(); System.out.println("version = " + version); cookiesDB.append(version); cookiesDB.append(","); boolean httpOnly = cookie.isHttpOnly(); System.out.println("httpOnly = " + httpOnly); cookiesDB.append(httpOnly); cookiesDB.append(","); cookie.setComment(""); cookie.setDomain(""); cookie.setHttpOnly(true); cookie.setMaxAge(0); cookie.setPath(""); cookie.setSecure(true); cookie.setValue(""); cookie.setVersion(0); System.out.println("name = " + name); System.out.println("value = " + value); } cookiesDB.append("]"); cookiesDB.deleteCharAt(cookiesDB.length()-2); System.out.println("cookiesDB = " + cookiesDB.toString()); } System.out.println("cookies = " + cookies); r.setCookies(cookiesDB.toString()); long dateHeader = request.getDateHeader("name"); r.setDateHeader(String.valueOf(dateHeader)); System.out.println("dateHeader = " + dateHeader); DispatcherType dispatcherType = request.getDispatcherType(); System.out.println("dispatcherType = " + dispatcherType); StringBuffer dispatcherTypeDB = new StringBuffer(); dispatcherTypeDB.append("["); String name = dispatcherType.name(); System.out.println("dispatcherType name = " + name); dispatcherTypeDB.append(name); dispatcherTypeDB.append(","); int ordinal = dispatcherType.ordinal(); System.out.println("dispatcherType ordinal = " + ordinal); dispatcherTypeDB.append(ordinal); dispatcherTypeDB.append(","); Class<DispatcherType> declaringClass = dispatcherType.getDeclaringClass(); System.out.println("dispatcherType declaringClass = " + declaringClass); dispatcherTypeDB.append(declaringClass); dispatcherTypeDB.append(","); dispatcherTypeDB.append("]"); dispatcherTypeDB.deleteCharAt(dispatcherTypeDB.length()-2); System.out.println("dispatcherTypeDB = " + dispatcherTypeDB.toString()); r.setDispatcherType(dispatcherTypeDB.toString()); //TODO 浏览器 String header = request.getHeader("User-Agent"); r.setHeader(header); System.out.println("header = " + header); Enumeration<String> headerNames = request.getHeaderNames(); StringBuffer headerNamesDB = new StringBuffer(); headerNamesDB.append("["); while (headerNames.hasMoreElements()) { String nextElement = (String) headerNames.nextElement(); headerNamesDB.append(nextElement); headerNamesDB.append(","); System.out.println("nextElement = " + nextElement); } headerNamesDB.append("]"); headerNamesDB.deleteCharAt(headerNamesDB.length()-2); r.setHeaderNames(headerNamesDB.toString()); System.out.println("headerNamesDB = " + headerNamesDB.toString()); System.out.println("headerNames = " + headerNames); Enumeration<String> headers = request.getHeaders("name"); StringBuffer headersDB = new StringBuffer(); headersDB.append("["); while (headers.hasMoreElements()) { String nextElement = (String) headers.nextElement(); headersDB.append(nextElement); headersDB.append(","); System.out.println("nextElement" + nextElement); } headersDB.append("]"); headersDB.deleteCharAt(headersDB.length()-2); r.setHeaders(headersDB.toString()); System.out.println("headersDB = " + headersDB); System.out.println("headers = " + headers); ServletInputStream inputStream = request.getInputStream(); r.setInputStream(inputStream.toString()); System.out.println("inputStream = " + inputStream); // long skip = inputStream.skip(0); // inputStream.reset(); // int read = inputStream.read(); // boolean markSupported = inputStream.markSupported(); // int available = inputStream.available(); // inputStream.close(); int intHeader = request.getIntHeader("name"); r.setIntHeader(String.valueOf(intHeader)); System.out.println("intHeader = " + intHeader); String localAddr = request.getLocalAddr(); r.setLocalAddr(localAddr); System.out.println("localAddr = " + localAddr); Locale locale = request.getLocale(); System.out.println("locale = " + locale); StringBuffer localeDB = new StringBuffer(); localeDB.append("["); Object clone = locale.clone(); System.out.println("locale clone = " + clone); localeDB.append(clone); localeDB.append(","); String country = locale.getCountry(); System.out.println("locale country = " + country); localeDB.append(country); localeDB.append(","); String displayCountry = locale.getDisplayCountry(); System.out.println("locale displayCountry = " + displayCountry); localeDB.append(displayCountry); localeDB.append(","); String displayLanguage = locale.getDisplayLanguage(); System.out.println("locale coundisplayLanguagetry = " + displayLanguage); localeDB.append(displayLanguage); localeDB.append(","); String displayName = locale.getDisplayName(); System.out.println("locale displayName = " + displayName); localeDB.append(displayName); localeDB.append(","); String displayScript = locale.getDisplayScript(); System.out.println("locale displayScript = " + displayScript); localeDB.append(displayScript); localeDB.append(","); String displayVariant = locale.getDisplayVariant(); System.out.println("locale displayVariant = " + displayVariant); localeDB.append(displayVariant); localeDB.append(","); String extension = locale.getExtension('a'); System.out.println("locale extension = " + extension); localeDB.append(extension); localeDB.append(","); Set<Character> extensionKeys = locale.getExtensionKeys(); System.out.println("locale extensionKeys = " + extensionKeys); localeDB.append(extensionKeys); localeDB.append(","); String iso3Country = locale.getISO3Country(); System.out.println("locale iso3Country = " + iso3Country); localeDB.append(iso3Country); localeDB.append(","); String iso3Language = locale.getISO3Language(); System.out.println("locale iso3Language = " +iso3Language); localeDB.append(iso3Language); localeDB.append(","); String language = locale.getLanguage(); System.out.println("locale language = " + language); localeDB.append(language); localeDB.append(","); String script = locale.getScript(); System.out.println("locale script = " + script); localeDB.append(script); localeDB.append(","); Set<String> unicodeLocaleAttributes = locale.getUnicodeLocaleAttributes(); System.out.println("locale unicodeLocaleAttributes = " + unicodeLocaleAttributes); localeDB.append(unicodeLocaleAttributes); localeDB.append(","); Set<String> unicodeLocaleKeys = locale.getUnicodeLocaleKeys(); System.out.println("locale unicodeLocaleKeys = " + unicodeLocaleKeys); localeDB.append(unicodeLocaleKeys); localeDB.append(","); String variant = locale.getVariant(); System.out.println("locale variant = " + variant); localeDB.append(variant); localeDB.append(","); boolean hasExtensions = locale.hasExtensions(); System.out.println("locale hasExtensions = " + hasExtensions); localeDB.append(hasExtensions); localeDB.append(","); int hashCode = locale.hashCode(); System.out.println("locale hashCode = " + hashCode); localeDB.append(hashCode); localeDB.append(","); Locale stripExtensions = locale.stripExtensions(); System.out.println("locale stripExtensions = " + stripExtensions); localeDB.append(stripExtensions); localeDB.append(","); String languageTag = locale.toLanguageTag(); System.out.println("locale languageTag = " + languageTag); localeDB.append(languageTag); localeDB.append(","); String string3 = locale.toString(); System.out.println("locale string3 = " + string3); localeDB.append(string3); localeDB.append(","); // Locale forLanguageTag = Locale.forLanguageTag(null); // System.out.println("locale forLanguageTag = " + forLanguageTag); // Locale[] availableLocales = Locale.getAvailableLocales(); System.out.println("locale availableLocales = " + availableLocales); localeDB.append(availableLocales); localeDB.append(","); Locale default1 = Locale.getDefault(); System.out.println("locale default1 = " + default1); localeDB.append(default1); localeDB.append(","); String[] isoCountries = Locale.getISOCountries(); System.out.println("locale isoCountries = " + isoCountries); localeDB.append(isoCountries); localeDB.append(","); String[] isoLanguages = Locale.getISOLanguages(); System.out.println("locale isoLanguages = " + isoLanguages); localeDB.append(isoLanguages); localeDB.append(","); localeDB.append("]"); localeDB.deleteCharAt(localeDB.length()-2); r.setLocale(localeDB.toString()); System.out.println("localeDB = " + localeDB.toString()); String localName = request.getLocalName(); r.setLocalName(localName); System.out.println("localName = " + localName); //TODO Enumeration<Locale> locales = request.getLocales(); while (locales.hasMoreElements()) { Locale nextElement = locales.nextElement(); String country1 = nextElement.getCountry(); System.out.println("locale country = " + country1); } r.setLocales(locales.toString()); System.out.println("locales = " + locales); int localPort = request.getLocalPort(); r.setLocalPort(String.valueOf(localPort)); System.out.println("localPort = " + localPort); String method = request.getMethod(); r.setMethod(method); System.out.println("method = " + method); String parameter = request.getParameter("name"); r.setParameter(parameter); System.out.println("parameter = " + parameter); //TODO Map<String, String[]> parameterMap = request.getParameterMap(); for (Entry<String, String[]> entry : parameterMap.entrySet()) { String[] parameter1 = entry.getValue(); System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue()); for (int i = 0; i < parameter1.length; i++) { String string2 = parameter1[i]; System.out.println("string2 = " + string2); } } r.setParameterMap(parameterMap.toString()); System.out.println("parameterMap = " + parameterMap); //TODO Enumeration<String> parameterNames = request.getParameterNames(); while (parameterNames.hasMoreElements()) { String string = (String) parameterNames.nextElement(); System.out.println("string = " + string); } r.setParameterNames(parameterNames.toString()); System.out.println("parameterNames = " + parameterNames); //TODO String[] parameterValues = request.getParameterValues("name"); if(parameterValues != null) { for (int i = 0; i < parameterValues.length; i++) { String string2 = parameterValues[i]; System.out.println("string2 = " + string2); } } if(parameterValues!=null) { r.setParameterValues(parameterValues.toString()); } System.out.println("parameterValues = " + parameterValues); Part part = request.getPart("name"); StringBuffer partDB = new StringBuffer(); partDB.append("["); if(part != null) { // part.delete(); String contentType2 = part.getContentType(); System.out.println("contentType2 = " + contentType2); partDB.append(contentType2); partDB.append(","); String header2 = part.getHeader(null); System.out.println("header2 = " + header2); partDB.append(header2); partDB.append(","); Collection<String> headerNames2 = part.getHeaderNames(); System.out.println("headerNames2 = " + headerNames2); partDB.append(headerNames2); partDB.append(","); InputStream inputStream2 = part.getInputStream(); System.out.println("inputStream2 = " + inputStream2); partDB.append(inputStream2); partDB.append(","); String name3 = part.getName(); System.out.println("name3 = " + name3); partDB.append(name3); partDB.append(","); long size = part.getSize(); System.out.println("size = " + size); partDB.append(size); partDB.append(","); System.out.println("name3 = " + name3); } localeDB.append("]"); localeDB.deleteCharAt(localeDB.length()-2); System.out.println("localeDB = " + localeDB.toString()); r.setPart(partDB.toString()); System.out.println("part = " + part); String pathInfo = request.getPathInfo(); r.setPathInfo(pathInfo); System.out.println("pathInfo = " + pathInfo); String pathTranslated = request.getPathTranslated(); r.setPathTranslated(pathTranslated); System.out.println("pathTranslated = " + pathTranslated); String protocol = request.getProtocol(); r.setProtocol(protocol); System.out.println("protocol = " + protocol); String queryString = request.getQueryString(); r.setQueryString(queryString); System.out.println("queryString = " + queryString); // BufferedReader reader = request.getReader(); // String readLine = reader.readLine(); // System.out.println("readLine = " + readLine); // System.out.println("reader = " + reader); String realPath = request.getRealPath("name"); r.setRealPath(realPath); System.out.println("realPath = " + realPath); String remoteAddr = request.getRemoteAddr(); r.setRemoteAddr(remoteAddr); System.out.println("remoteAddr = " + remoteAddr); String remoteHost = request.getRemoteHost(); r.setRemoteHost(remoteHost); //TODO request.setAttribute("ip", remoteHost); System.out.println("remoteHost = " + remoteHost); int remotePort = request.getRemotePort(); r.setRemotePort(String.valueOf(remotePort)); System.out.println("remotePort = " + remotePort); String remoteUser = request.getRemoteUser(); r.setRemoteUser(remoteUser); System.out.println("remoteUser = " + remoteUser); //TODO RequestDispatcher requestDispatcher = request.getRequestDispatcher("name"); // requestDispatcher.forward(request, response); // requestDispatcher.include(request, response); String name3 = requestDispatcher.getClass().getName(); System.out.println("name3 = " + name3); r.setRequestDispatcher(requestDispatcher.toString()); System.out.println("requestDispatcher = " + requestDispatcher); String requestURI = request.getRequestURI(); r.setRequestURI(requestURI); System.out.println("requestURI = " + requestURI); String requestedSessionId = request.getRequestedSessionId(); r.setRequestedSessionId(requestedSessionId); System.out.println("requestedSessionId = " + requestedSessionId); StringBuffer requestURL = request.getRequestURL(); r.setRequestURL(requestURL.toString()); System.out.println("requestURL = " + requestURL.toString()); String scheme = request.getScheme(); r.setScheme(scheme); System.out.println("scheme = " + scheme); String serverName = request.getServerName(); r.setServerName(serverName); System.out.println("serverName = " + serverName); int serverPort = request.getServerPort(); r.setServerPort(String.valueOf(serverPort)); System.out.println("serverPort = " + serverPort); ServletContext servletContext = request.getServletContext(); r.setServletContext(servletContext.toString()); // String contextPath2 = servletContext.getContextPath(); // Enumeration<String> attributeNames2 = servletContext.getAttributeNames(); // ClassLoader classLoader = servletContext.getClassLoader(); // String contextPath3 = servletContext.getContextPath(); // Set<SessionTrackingMode> defaultSessionTrackingModes = servletContext.getDefaultSessionTrackingModes(); // Map<String, ? extends FilterRegistration> filterRegistrations = servletContext.getFilterRegistrations(); // Set<SessionTrackingMode> effectiveSessionTrackingModes = servletContext.getEffectiveSessionTrackingModes(); // int effectiveMajorVersion = servletContext.getEffectiveMajorVersion(); // // System.out.println("contextPath2 = " + contextPath2); // System.out.println("servletContext = " + servletContext); String servletPath = request.getServletPath(); r.setServletPath(servletPath); System.out.println("servletPath = " + servletPath); //TODO session HttpSession session = request.getSession(); r.setSession(session.toString()); long creationTime = session.getCreationTime(); System.out.println("creationTime = " + creationTime); System.out.println("session = " + session); HttpSession session2 = request.getSession(true); System.out.println("session2 = " + session2); //TODO Principal userPrincipal = request.getUserPrincipal(); if(userPrincipal != null) { String string = userPrincipal.toString(); System.out.println("string = " + string); String name4 = userPrincipal.getName(); System.out.println("name4 = " + name4); System.out.println("userPrincipal = " + userPrincipal); } if(userPrincipal!=null) { r.setUserPrincipal(userPrincipal.toString()); } boolean asyncStarted = request.isAsyncStarted(); r.setAsyncStarted(String.valueOf(asyncStarted)); System.out.println("asyncStarted = " + asyncStarted); boolean asyncSupported = request.isAsyncSupported(); r.setAsyncSupported(String.valueOf(asyncSupported)); System.out.println("asyncSupported = " + asyncSupported); boolean requestedSessionIdFromCookie = request.isRequestedSessionIdFromCookie(); r.setRequestedSessionIdFromCookie(String.valueOf(requestedSessionIdFromCookie)); System.out.println("requestedSessionIdFromCookie = " + requestedSessionIdFromCookie); boolean requestedSessionIdFromUrl = request.isRequestedSessionIdFromUrl(); r.setRequestedSessionIdFromUrl(String.valueOf(requestedSessionIdFromUrl)); System.out.println("requestedSessionIdFromUrl = " + requestedSessionIdFromUrl); boolean requestedSessionIdFromURL2 = request.isRequestedSessionIdFromURL(); System.out.println("requestedSessionIdFromURL2 = " + requestedSessionIdFromURL2); boolean requestedSessionIdValid = request.isRequestedSessionIdValid(); r.setRequestedSessionIdValid(String.valueOf(requestedSessionIdValid)); System.out.println("requestedSessionIdValid = " + requestedSessionIdValid); boolean secure = request.isSecure(); r.setSecure(String.valueOf(secure)); System.out.println("secure = " + secure); boolean userInRole = request.isUserInRole("name"); r.setUserInRole(String.valueOf(userInRole)); System.out.println("userInRole = " + userInRole); // request.login("name", "name2"); // System.out.println("string = " + string); // request.logout(); // System.out.println("string = " + string); request.removeAttribute("name"); r.setRemoveAttribute("removeAttribute"); // System.out.println("string = " + string); request.setAttribute("name", "name1"); r.setSetAttribute("setAttribute"); // System.out.println("string = " + string); request.setCharacterEncoding("utf-8"); r.setSetCharacterEncoding("setCharacterEncoding"); // System.out.println("string = " + string); // AsyncContext startAsync = request.startAsync(); // long timeout = startAsync.getTimeout(); // System.out.println("timeout = " + timeout); // System.out.println("startAsync = " + startAsync); // // AsyncContext startAsync2 = request.startAsync(request, response); // long timeout1 = startAsync.getTimeout(); // System.out.println("timeout1 = " + timeout1); // System.out.println("startAsync2 = " + startAsync2); String basicAuth = request.BASIC_AUTH; r.setBasicAuth(basicAuth); System.out.println("basicAuth = " + basicAuth); String clientCertAuth = request.CLIENT_CERT_AUTH; r.setClientCertAuth(clientCertAuth); System.out.println("clientCertAuth = " + clientCertAuth); String digestAuth = request.DIGEST_AUTH; r.setDigestAuth(digestAuth); System.out.println("digestAuth = " + digestAuth); String formAuth = request.FORM_AUTH; r.setFormAuth(formAuth); System.out.println("formAuth = " + formAuth); //TODO 得到浏览器名称和操作系统名称 // StringTokenizer st = new StringTokenizer(header,";"); // st.nextToken(); // if(st.hasMoreTokens()) // { // //得到用户的浏览器名 // String userBrowser = st.nextToken(); // r.setUserBrowser(userBrowser); // //得到用户的操作系统名 // String userOs = st.nextToken(); // r.setUserOs(userOs); // } String accept = request.getHeader("Accept"); r.setHeaderAccept(accept); System.out.println("accept = " + accept); String host = request.getHeader("Host"); r.setHeaderHost(host); System.out.println("host = " + host); String referer = request.getHeader("Referer"); r.setHeaderReferer(referer); System.out.println("referer = " + referer); String Accept_Language = request.getHeader("Accept-Language"); r.setHeaderAcceptLanguage(Accept_Language); System.out.println("Accept-Language = " + Accept_Language); String Accept_Encoding = request.getHeader("Accept-Encoding"); r.setHeaderAcceptEncoding(Accept_Encoding); System.out.println("Accept-Encoding = " + Accept_Encoding); String connection = request.getHeader("Connection"); r.setHeaderConnection(connection); System.out.println("connection = " + connection); String cookie = request.getHeader("Cookie"); r.setHeaderCookie(cookie); System.out.println("cookie = " + cookie); String Cache_Control = request.getHeader("Cache-Control"); r.setHeaderCacheControl(Cache_Control); System.out.println("Cache_Control = " + Cache_Control); String server = request.getHeader("Server"); r.setHeaderServer(server); System.out.println("server = " + server); String Content_Length = request.getHeader("Content-Length"); r.setHeaderContentLength(Content_Length); System.out.println("Content-Length = " + Content_Length); String Content_Type = request.getHeader("Content-Type"); r.setHeaderContentType(Content_Type); System.out.println("Content-Type = " + Content_Type); String date = request.getHeader("Date"); r.setHeaderDate(date); System.out.println("date = " + date); String expires = request.getHeader("Expires"); r.setHeaderExpires(expires); System.out.println("Expires = " + expires); String Transfer_Encoding = request.getHeader("Transfer-Encoding"); r.setHeaderTransferEncoding(Transfer_Encoding); System.out.println("Transfer-Encoding = " + Transfer_Encoding); String Vary = request.getHeader("Vary"); r.setHeaderVary(Vary); System.out.println("Vary = " + Vary); String x_forwarded_for = request.getHeader("x-forwarded-for"); // r.setHeaderVary(Vary); System.out.println("x-forwarded-for = " + x_forwarded_for); //hibernate Entity Save Session sessionHiber = DBhelper.getSessionFactory().openSession(); sessionHiber.beginTransaction(); sessionHiber.save(r); sessionHiber.getTransaction().commit(); sessionHiber.close(); request.getRequestDispatcher("ok.jsp").forward(request, response); } /** * @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse) */ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doPut()"); } /** * @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse) */ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doDelete()"); } /** * @see HttpServlet#doHead(HttpServletRequest, HttpServletResponse) */ protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doHead()"); } /** * @see HttpServlet#doOptions(HttpServletRequest, HttpServletResponse) */ protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doOptions()"); } /** * @see HttpServlet#doTrace(HttpServletRequest, HttpServletResponse) */ protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doTrace()"); } }
下一篇: HDU-3364-*s
推荐阅读
-
request 参数 博客分类: Java语言_Utils HttpServletRequestrequest参数
-
WEB前端的jQuery程序语言 博客分类: 互联网Java jquery元素参数true克隆
-
JdbcTemplate进行in查询随机数量参数的SQL简单拼写 博客分类: java;
-
JSP中使用window.location.href()跳转和传递参数。 博客分类: Java Web 页面跳转
-
JAVA基础----解决get方法传递URL参数中文乱码问题 博客分类: JAVA基础 get 乱码 servlet
-
java读取.properties属性文件并格式化参数 博客分类: java基础
-
Java参数传递机制 博客分类: java JavaBlog
-
Java中通过System.getProperties()获取系统参数 博客分类: Java Java虚拟机OSUnixEXT
-
Java中通过System.getProperties()获取系统参数 博客分类: Java Java虚拟机OSUnixEXT
-
spring MVC 获取请求体 博客分类: spring MVC 请求参数请求要素request stringrequest bodyspringMVC获取请求体