List of usage examples for javax.servlet.http HttpServletRequest getProtocol
public String getProtocol();
From source file:org.getobjects.servlets.WOServletRequest.java
/** * Initialize the WORequest object with the data contained in the * HttpServletRequest.// ww w . j ava 2s. c om * This will load the HTTP headers from the servlet request into the * WORequest, * it will decode cookies, * it will decode query parameters and form values * and it will process the content. * * @param _rq - the HttpServletRequest * @param _r - the HttpServletResponse */ @SuppressWarnings("unchecked") protected void init(final HttpServletRequest _rq, final HttpServletResponse _r) { this.init(_rq.getMethod(), _rq.getRequestURI(), _rq.getProtocol(), null /* headers */, null /* contents */, null /* userInfo */); this.sRequest = _rq; this.sResponse = _r; this.loadHeadersFromServletRequest(_rq); this.loadCookies(); // Note: ServletFileUpload.isMultipartContent() is deprecated String contentType = this.headerForKey("content-type"); if (contentType != null) contentType = contentType.toLowerCase(); if (contentType != null && contentType.startsWith("multipart/form-data")) { final FileItemFactory factory = // Apache stuff new DiskFileItemFactory(maxRAMFileSize, tmpFileLocation); final ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(maxRequestSize); List<FileItem> items = null; try { items = upload.parseRequest(_rq); } catch (FileUploadException e) { items = null; log.error("failed to parse upload request", e); } /* load regular form values (query parameters) */ this.loadFormValuesFromRequest(_rq); /* next load form values from file items */ this.loadFormValuesFromFileItems(items); } else if (contentType != null && contentType.startsWith("application/x-www-form-urlencoded")) { /* Note: we need to load form values first, because when we load the * content, we need to process them on our own. */ this.loadFormValuesFromRequest(_rq); /* Note: since we made the Servlet container process the form content, * we can't load any content ... */ } else { /* Note: we need to load form values first, because when we load the * content, we need to process them on our own. */ this.loadFormValuesFromRequest(_rq); // TODO: make this smarter, eg transfer large PUTs to disk this.loadContentFromRequest(_rq); } }
From source file:org.hoteia.qalingo.core.web.bean.clickstream.ClickstreamRequest.java
public ClickstreamRequest(HttpServletRequest request, Date timestamp) { protocol = request.getProtocol(); serverName = request.getServerName(); serverPort = request.getServerPort(); requestURI = request.getRequestURI(); queryString = request.getQueryString(); remoteUser = request.getRemoteUser(); this.timestamp = timestamp; }
From source file:org.jahia.bin.errors.ErrorLoggingFilter.java
/** * Returns the request information for logging purposes. * * @param request the http request object * @return the request information for logging purposes *//* w w w . ja v a 2s . c o m*/ private static String getRequestInfo(HttpServletRequest request) { StringBuilder info = new StringBuilder(512); if (request != null) { String uri = (String) request.getAttribute("javax.servlet.error.request_uri"); String queryString = (String) request.getAttribute("javax.servlet.forward.query_string"); if (StringUtils.isNotEmpty(queryString)) { uri = uri + "?" + queryString; } info.append("Request information:").append("\nURL: ").append(uri).append("\nMethod: ") .append(request.getMethod()).append("\nProtocol: ").append(request.getProtocol()) .append("\nRemote host: ").append(request.getRemoteHost()).append("\nRemote address: ") .append(request.getRemoteAddr()).append("\nRemote port: ").append(request.getRemotePort()) .append("\nRemote user: ").append(request.getRemoteUser()).append("\nSession ID: ") .append(request.getRequestedSessionId()).append("\nSession user: ").append(getUserInfo(request)) .append("\nRequest headers: "); @SuppressWarnings("unchecked") Iterator<String> headerNames = new EnumerationIterator(request.getHeaderNames()); while (headerNames.hasNext()) { String headerName = headerNames.next(); String headerValue = request.getHeader(headerName); info.append("\n ").append(headerName).append(": ").append(headerValue); } } return info.toString(); }
From source file:org.josso.gl2.gateway.reverseproxy.ReverseProxyValve.java
/** * This method calculates the reverse-proxy-host header value. */// w w w.j a v a2 s . c o m protected String getReverseProxyHost(Request request) { HttpServletRequest hsr = (HttpServletRequest) request.getRequest(); if (_reverseProxyHost == null) { synchronized (this) { String h = hsr.getProtocol().substring(0, hsr.getProtocol().indexOf("/")).toLowerCase() + "://" + hsr.getServerName() + (hsr.getServerPort() != 80 ? (":" + hsr.getServerPort()) : ""); _reverseProxyHost = h; } } return _reverseProxyHost; }
From source file:ORG.oclc.os.SRW.SRWServlet.java
/** * Return the HTTP protocol level 1.1 or 1.0 * by derived class.// www. j av a2 s .c o m * @return one of the HTTPConstants values */ protected String getProtocolVersion(HttpServletRequest req) { String ret = HTTPConstants.HEADER_PROTOCOL_V10; String prot = req.getProtocol(); if (prot != null) { int sindex = prot.indexOf('/'); if (-1 != sindex) { String ver = prot.substring(sindex + 1); if (HTTPConstants.HEADER_PROTOCOL_V11.equals(ver.trim())) { ret = HTTPConstants.HEADER_PROTOCOL_V11; } } } return ret; }
From source file:org.ofbiz.content.data.DataEvents.java
/** Streams any binary content data to the browser */ public static String serveObjectData(HttpServletRequest request, HttpServletResponse response) { Delegator delegator = (Delegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); HttpSession session = request.getSession(); Locale locale = UtilHttp.getLocale(request); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); String userAgent = request.getHeader("User-Agent"); Map<String, Object> httpParams = UtilHttp.getParameterMap(request); String contentId = (String) httpParams.get("contentId"); if (UtilValidate.isEmpty(contentId)) { String errorMsg = "Required parameter contentId not found!"; Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; }/*from w w w . ja va 2s .co m*/ // get the permission service required for streaming data; default is always the genericContentPermission String permissionService = EntityUtilProperties.getPropertyValue("content.properties", "stream.permission.service", "genericContentPermission", delegator); // get the content record GenericValue content; try { content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } // make sure content exists if (content == null) { String errorMsg = "No content found for Content ID: " + contentId; Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; } // make sure there is a DataResource for this content String dataResourceId = content.getString("dataResourceId"); if (UtilValidate.isEmpty(dataResourceId)) { String errorMsg = "No Data Resource found for Content ID: " + contentId; Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; } // get the data resource GenericValue dataResource; try { dataResource = EntityQuery.use(delegator).from("DataResource").where("dataResourceId", dataResourceId) .queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } // make sure the data resource exists if (dataResource == null) { String errorMsg = "No Data Resource found for ID: " + dataResourceId; Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; } // see if data resource is public or not String isPublic = dataResource.getString("isPublic"); if (UtilValidate.isEmpty(isPublic)) { isPublic = "N"; } // not public check security if (!"Y".equalsIgnoreCase(isPublic)) { // do security check Map<String, ? extends Object> permSvcCtx = UtilMisc.toMap("userLogin", userLogin, "locale", locale, "mainAction", "VIEW", "contentId", contentId); Map<String, Object> permSvcResp; try { permSvcResp = dispatcher.runSync(permissionService, permSvcCtx); } catch (GenericServiceException e) { Debug.logError(e, module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } if (ServiceUtil.isError(permSvcResp)) { String errorMsg = ServiceUtil.getErrorMessage(permSvcResp); Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; } // no service errors; now check the actual response Boolean hasPermission = (Boolean) permSvcResp.get("hasPermission"); if (!hasPermission.booleanValue()) { String errorMsg = (String) permSvcResp.get("failMessage"); Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; } } // get objects needed for data processing String contextRoot = (String) request.getAttribute("_CONTEXT_ROOT_"); String webSiteId = (String) session.getAttribute("webSiteId"); String dataName = dataResource.getString("dataResourceName"); // get the mime type String mimeType = DataResourceWorker.getMimeType(dataResource); // hack for IE and mime types if (userAgent.indexOf("MSIE") > -1) { Debug.logInfo("Found MSIE changing mime type from - " + mimeType, module); mimeType = "application/octet-stream"; } // for local resources; use HTTPS if we are requested via HTTPS String https = "false"; String protocol = request.getProtocol(); if ("https".equalsIgnoreCase(protocol)) { https = "true"; } // get the data resource stream and conent length Map<String, Object> resourceData; try { resourceData = DataResourceWorker.getDataResourceStream(dataResource, https, webSiteId, locale, contextRoot, false); } catch (IOException e) { Debug.logError(e, "Error getting DataResource stream", module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } catch (GeneralException e) { Debug.logError(e, "Error getting DataResource stream", module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); return "error"; } // get the stream data InputStream stream = null; Long length = null; if (resourceData != null) { stream = (InputStream) resourceData.get("stream"); length = (Long) resourceData.get("length"); } Debug.logInfo("Got resource data stream: " + length + " bytes", module); // stream the content to the browser if (stream != null && length != null) { try { UtilHttp.streamContentToBrowser(response, stream, length.intValue(), mimeType, dataName); } catch (IOException e) { Debug.logError(e, "Unable to write content to browser", module); request.setAttribute("_ERROR_MESSAGE_", e.getMessage()); // this must be handled with a special error string because the output stream has been already used and we will not be able to return the error page; // the "io-error" should be associated to a response of type "none" return "io-error"; } } else { String errorMsg = "No data is available."; Debug.logError(errorMsg, module); request.setAttribute("_ERROR_MESSAGE_", errorMsg); return "error"; } return "success"; }
From source file:org.openqa.jetty.servlet.Dump.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("Dump", this); request.setCharacterEncoding("ISO_8859_1"); getServletContext().setAttribute("Dump", this); String info = request.getPathInfo(); if (info != null && info.endsWith("Exception")) { try {/*from w w w. ja v a2 s . co m*/ throw (Throwable) (Loader.loadClass(this.getClass(), info.substring(1)).newInstance()); } catch (Throwable th) { throw new ServletException(th); } } String redirect = request.getParameter("redirect"); if (redirect != null && redirect.length() > 0) { response.getOutputStream().println("THIS SHOULD NOT BE SEEN!"); response.sendRedirect(redirect); response.getOutputStream().println("THIS SHOULD NOT BE SEEN!"); return; } String error = request.getParameter("error"); if (error != null && error.length() > 0) { response.getOutputStream().println("THIS SHOULD NOT BE SEEN!"); response.sendError(Integer.parseInt(error)); response.getOutputStream().println("THIS SHOULD NOT BE SEEN!"); return; } String length = request.getParameter("length"); if (length != null && length.length() > 0) { response.setContentLength(Integer.parseInt(length)); } String buffer = request.getParameter("buffer"); if (buffer != null && buffer.length() > 0) response.setBufferSize(Integer.parseInt(buffer)); request.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); if (info != null && info.indexOf("Locale/") >= 0) { try { String locale_name = info.substring(info.indexOf("Locale/") + 7); Field f = java.util.Locale.class.getField(locale_name); response.setLocale((Locale) f.get(null)); } catch (Exception e) { LogSupport.ignore(log, e); response.setLocale(Locale.getDefault()); } } String cn = request.getParameter("cookie"); String cv = request.getParameter("value"); String v = request.getParameter("version"); if (cn != null && cv != null) { Cookie cookie = new Cookie(cn, cv); cookie.setComment("Cookie from dump servlet"); if (v != null) { cookie.setMaxAge(300); cookie.setPath("/"); cookie.setVersion(Integer.parseInt(v)); } response.addCookie(cookie); } String pi = request.getPathInfo(); if (pi != null && pi.startsWith("/ex")) { OutputStream out = response.getOutputStream(); out.write("</H1>This text should be reset</H1>".getBytes()); if ("/ex0".equals(pi)) throw new ServletException("test ex0", new Throwable()); if ("/ex1".equals(pi)) throw new IOException("test ex1"); if ("/ex2".equals(pi)) throw new UnavailableException("test ex2"); if ("/ex3".equals(pi)) throw new HttpException(501); } PrintWriter pout = response.getWriter(); Page page = null; try { page = new Page(); page.title("Dump Servlet"); page.add(new Heading(1, "Dump Servlet")); Table table = new Table(0).cellPadding(0).cellSpacing(0); page.add(table); table.newRow(); table.addHeading("getMethod: ").cell().right(); table.addCell("" + request.getMethod()); table.newRow(); table.addHeading("getContentLength: ").cell().right(); table.addCell(Integer.toString(request.getContentLength())); table.newRow(); table.addHeading("getContentType: ").cell().right(); table.addCell("" + request.getContentType()); table.newRow(); table.addHeading("getCharacterEncoding: ").cell().right(); table.addCell("" + request.getCharacterEncoding()); table.newRow(); table.addHeading("getRequestURI: ").cell().right(); table.addCell("" + request.getRequestURI()); table.newRow(); table.addHeading("getRequestURL: ").cell().right(); table.addCell("" + request.getRequestURL()); table.newRow(); table.addHeading("getContextPath: ").cell().right(); table.addCell("" + request.getContextPath()); table.newRow(); table.addHeading("getServletPath: ").cell().right(); table.addCell("" + request.getServletPath()); table.newRow(); table.addHeading("getPathInfo: ").cell().right(); table.addCell("" + request.getPathInfo()); table.newRow(); table.addHeading("getPathTranslated: ").cell().right(); table.addCell("" + request.getPathTranslated()); table.newRow(); table.addHeading("getQueryString: ").cell().right(); table.addCell("" + request.getQueryString()); table.newRow(); table.addHeading("getProtocol: ").cell().right(); table.addCell("" + request.getProtocol()); table.newRow(); table.addHeading("getScheme: ").cell().right(); table.addCell("" + request.getScheme()); table.newRow(); table.addHeading("getServerName: ").cell().right(); table.addCell("" + request.getServerName()); table.newRow(); table.addHeading("getServerPort: ").cell().right(); table.addCell("" + Integer.toString(request.getServerPort())); table.newRow(); table.addHeading("getLocalName: ").cell().right(); table.addCell("" + request.getLocalName()); table.newRow(); table.addHeading("getLocalAddr: ").cell().right(); table.addCell("" + request.getLocalAddr()); table.newRow(); table.addHeading("getLocalPort: ").cell().right(); table.addCell("" + Integer.toString(request.getLocalPort())); table.newRow(); table.addHeading("getRemoteUser: ").cell().right(); table.addCell("" + request.getRemoteUser()); table.newRow(); table.addHeading("getRemoteAddr: ").cell().right(); table.addCell("" + request.getRemoteAddr()); table.newRow(); table.addHeading("getRemoteHost: ").cell().right(); table.addCell("" + request.getRemoteHost()); table.newRow(); table.addHeading("getRemotePort: ").cell().right(); table.addCell("" + request.getRemotePort()); table.newRow(); table.addHeading("getRequestedSessionId: ").cell().right(); table.addCell("" + request.getRequestedSessionId()); table.newRow(); table.addHeading("isSecure(): ").cell().right(); table.addCell("" + request.isSecure()); table.newRow(); table.addHeading("isUserInRole(admin): ").cell().right(); table.addCell("" + request.isUserInRole("admin")); table.newRow(); table.addHeading("getLocale: ").cell().right(); table.addCell("" + request.getLocale()); Enumeration locales = request.getLocales(); while (locales.hasMoreElements()) { table.newRow(); table.addHeading("getLocales: ").cell().right(); table.addCell(locales.nextElement()); } table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Other HTTP Headers") .attribute("COLSPAN", "2").left(); Enumeration h = request.getHeaderNames(); String name; while (h.hasMoreElements()) { name = (String) h.nextElement(); Enumeration h2 = request.getHeaders(name); while (h2.hasMoreElements()) { String hv = (String) h2.nextElement(); table.newRow(); table.addHeading(name + ": ").cell().right(); table.addCell(hv); } } table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Request Parameters") .attribute("COLSPAN", "2").left(); h = request.getParameterNames(); while (h.hasMoreElements()) { name = (String) h.nextElement(); table.newRow(); table.addHeading(name + ": ").cell().right(); table.addCell(request.getParameter(name)); String[] values = request.getParameterValues(name); if (values == null) { table.newRow(); table.addHeading(name + " Values: ").cell().right(); table.addCell("NULL!!!!!!!!!"); } else if (values.length > 1) { for (int i = 0; i < values.length; i++) { table.newRow(); table.addHeading(name + "[" + i + "]: ").cell().right(); table.addCell(values[i]); } } } table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Cookies").attribute("COLSPAN", "2").left(); Cookie[] cookies = request.getCookies(); for (int i = 0; cookies != null && i < cookies.length; i++) { Cookie cookie = cookies[i]; table.newRow(); table.addHeading(cookie.getName() + ": ").cell().attribute("VALIGN", "TOP").right(); table.addCell(cookie.getValue()); } /* ------------------------------------------------------------ */ table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Request Attributes") .attribute("COLSPAN", "2").left(); Enumeration a = request.getAttributeNames(); while (a.hasMoreElements()) { name = (String) a.nextElement(); table.newRow(); table.addHeading(name + ": ").cell().attribute("VALIGN", "TOP").right(); table.addCell("<pre>" + toString(request.getAttribute(name)) + "</pre>"); } /* ------------------------------------------------------------ */ table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Servlet InitParameters") .attribute("COLSPAN", "2").left(); a = getInitParameterNames(); while (a.hasMoreElements()) { name = (String) a.nextElement(); table.newRow(); table.addHeading(name + ": ").cell().attribute("VALIGN", "TOP").right(); table.addCell("<pre>" + toString(getInitParameter(name)) + "</pre>"); } table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Context InitParameters") .attribute("COLSPAN", "2").left(); a = getServletContext().getInitParameterNames(); while (a.hasMoreElements()) { name = (String) a.nextElement(); table.newRow(); table.addHeading(name + ": ").cell().attribute("VALIGN", "TOP").right(); table.addCell("<pre>" + toString(getServletContext().getInitParameter(name)) + "</pre>"); } table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Context Attributes") .attribute("COLSPAN", "2").left(); a = getServletContext().getAttributeNames(); while (a.hasMoreElements()) { name = (String) a.nextElement(); table.newRow(); table.addHeading(name + ": ").cell().attribute("VALIGN", "TOP").right(); table.addCell("<pre>" + toString(getServletContext().getAttribute(name)) + "</pre>"); } if (request.getContentType() != null && request.getContentType().startsWith("multipart/form-data") && request.getContentLength() < 1000000) { MultiPartRequest multi = new MultiPartRequest(request); String[] parts = multi.getPartNames(); table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Multi-part content") .attribute("COLSPAN", "2").left(); for (int p = 0; p < parts.length; p++) { name = parts[p]; table.newRow(); table.addHeading(name + ": ").cell().attribute("VALIGN", "TOP").right(); table.addCell("<pre>" + multi.getString(parts[p]) + "</pre>"); } } String res = request.getParameter("resource"); if (res != null && res.length() > 0) { table.newRow(); table.newHeading().cell().nest(new Font(2, true)).add("<BR>Get Resource: " + res) .attribute("COLSPAN", "2").left(); table.newRow(); table.addHeading("this.getClass(): ").cell().right(); table.addCell("" + this.getClass().getResource(res)); table.newRow(); table.addHeading("this.getClass().getClassLoader(): ").cell().right(); table.addCell("" + this.getClass().getClassLoader().getResource(res)); table.newRow(); table.addHeading("Thread.currentThread().getContextClassLoader(): ").cell().right(); table.addCell("" + Thread.currentThread().getContextClassLoader().getResource(res)); table.newRow(); table.addHeading("getServletContext(): ").cell().right(); try { table.addCell("" + getServletContext().getResource(res)); } catch (Exception e) { table.addCell("" + e); } } /* ------------------------------------------------------------ */ page.add(Break.para); page.add(new Heading(1, "Request Wrappers")); ServletRequest rw = request; int w = 0; while (rw != null) { page.add((w++) + ": " + rw.getClass().getName() + "<br/>"); if (rw instanceof HttpServletRequestWrapper) rw = ((HttpServletRequestWrapper) rw).getRequest(); else if (rw instanceof ServletRequestWrapper) rw = ((ServletRequestWrapper) rw).getRequest(); else rw = null; } page.add(Break.para); page.add(new Heading(1, "International Characters")); page.add("Directly encoced: Drst<br/>"); page.add("HTML reference: Dürst<br/>"); page.add("Decimal (252) 8859-1: Dürst<br/>"); page.add("Hex (xFC) 8859-1: Dürst<br/>"); page.add( "Javascript unicode (00FC) : <script language='javascript'>document.write(\"D\u00FCrst\");</script><br/>"); page.add(Break.para); page.add(new Heading(1, "Form to generate GET content")); TableForm tf = new TableForm(response.encodeURL(getURI(request))); tf.method("GET"); tf.addTextField("TextField", "TextField", 20, "value"); tf.addButton("Action", "Submit"); page.add(tf); page.add(Break.para); page.add(new Heading(1, "Form to generate POST content")); tf = new TableForm(response.encodeURL(getURI(request))); tf.method("POST"); tf.addTextField("TextField", "TextField", 20, "value"); Select select = tf.addSelect("Select", "Select", true, 3); select.add("ValueA"); select.add("ValueB1,ValueB2"); select.add("ValueC"); tf.addButton("Action", "Submit"); page.add(tf); page.add(new Heading(1, "Form to upload content")); tf = new TableForm(response.encodeURL(getURI(request))); tf.method("POST"); tf.attribute("enctype", "multipart/form-data"); tf.addFileField("file", "file"); tf.addButton("Upload", "Upload"); page.add(tf); page.add(new Heading(1, "Form to get Resource")); tf = new TableForm(response.encodeURL(getURI(request))); tf.method("POST"); tf.addTextField("resource", "resource", 20, ""); tf.addButton("Action", "getResource"); page.add(tf); } catch (Exception e) { log.warn(LogSupport.EXCEPTION, e); } page.write(pout); String data = request.getParameter("data"); if (data != null && data.length() > 0) { int d = Integer.parseInt(data); while (d > 0) { pout.println("1234567890123456789012345678901234567890123456789\n"); d = d - 50; } } pout.close(); if (pi != null) { if ("/ex4".equals(pi)) throw new ServletException("test ex4", new Throwable()); if ("/ex5".equals(pi)) throw new IOException("test ex5"); if ("/ex6".equals(pi)) throw new UnavailableException("test ex6"); if ("/ex7".equals(pi)) throw new HttpException(501); } request.getInputStream().close(); }
From source file:org.pentaho.cdf.CdfApi.java
@GET @Path("/cdf-embed.js") @Produces(JAVASCRIPT)/*from ww w . j a v a 2 s . c o m*/ public void getCdfEmbeddedContext(@Context HttpServletRequest servletRequest, @Context HttpServletResponse servletResponse) throws Exception { buildCdfEmbedContext(servletRequest.getProtocol(), servletRequest.getServerName(), servletRequest.getServerPort(), servletRequest.getSession().getMaxInactiveInterval(), servletRequest.getParameter("locale"), servletRequest, servletResponse); }
From source file:org.robotframework.remoteserver.servlet.RemoteServerServlet.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { /*/*from ww w .ja v a 2 s .c om*/ * when the client is Jython 2.5.x (old xmlrpclib using HTTP/1.0), the * server's sockets got stuck in FIN_WAIT_2 for some time, eventually * hitting the limit of open sockets on some Windows systems. adding * this header gets the web server to close the socket. */ String path = req.getPathInfo() == null ? req.getServletPath() : req.getPathInfo(); path = cleanPath(path); if (libraryMap.containsKey(path)) { currLibrary.set(libraryMap.get(path)); if ("HTTP/1.0".equals(req.getProtocol())) resp.addHeader("Connection", "close"); super.doPost(req, resp); } else { resp.sendError(HttpServletResponse.SC_NOT_FOUND, String.format("No library mapped to %s", path)); } }
From source file:org.sakaiproject.dav.DavServlet.java
/** * Show HTTP header information./*from www . j a v a 2 s . c o m*/ */ @SuppressWarnings("unchecked") protected void showRequestInfo(HttpServletRequest req) { if (M_log.isDebugEnabled()) M_log.debug("DefaultServlet Request Info"); // Show generic info if (M_log.isDebugEnabled()) M_log.debug("Encoding : " + req.getCharacterEncoding()); if (M_log.isDebugEnabled()) M_log.debug("Length : " + req.getContentLength()); if (M_log.isDebugEnabled()) M_log.debug("Type : " + req.getContentType()); if (M_log.isDebugEnabled()) M_log.debug("Parameters"); Enumeration parameters = req.getParameterNames(); while (parameters.hasMoreElements()) { String paramName = (String) parameters.nextElement(); String[] values = req.getParameterValues(paramName); System.out.print(paramName + " : "); for (int i = 0; i < values.length; i++) { System.out.print(values[i] + ", "); } } if (M_log.isDebugEnabled()) M_log.debug("Protocol : " + req.getProtocol()); if (M_log.isDebugEnabled()) M_log.debug("Address : " + req.getRemoteAddr()); if (M_log.isDebugEnabled()) M_log.debug("Host : " + req.getRemoteHost()); if (M_log.isDebugEnabled()) M_log.debug("Scheme : " + req.getScheme()); if (M_log.isDebugEnabled()) M_log.debug("Server Name : " + req.getServerName()); if (M_log.isDebugEnabled()) M_log.debug("Server Port : " + req.getServerPort()); if (M_log.isDebugEnabled()) M_log.debug("Attributes"); Enumeration attributes = req.getAttributeNames(); while (attributes.hasMoreElements()) { String attributeName = (String) attributes.nextElement(); System.out.print(attributeName + " : "); if (M_log.isDebugEnabled()) M_log.debug(req.getAttribute(attributeName).toString()); } // Show HTTP info if (M_log.isDebugEnabled()) M_log.debug("HTTP Header Info"); if (M_log.isDebugEnabled()) M_log.debug("Authentication Type : " + req.getAuthType()); if (M_log.isDebugEnabled()) M_log.debug("HTTP Method : " + req.getMethod()); if (M_log.isDebugEnabled()) M_log.debug("Path Info : " + req.getPathInfo()); if (M_log.isDebugEnabled()) M_log.debug("Path translated : " + req.getPathTranslated()); if (M_log.isDebugEnabled()) M_log.debug("Query string : " + req.getQueryString()); if (M_log.isDebugEnabled()) M_log.debug("Remote user : " + req.getRemoteUser()); if (M_log.isDebugEnabled()) M_log.debug("Requested session id : " + req.getRequestedSessionId()); if (M_log.isDebugEnabled()) M_log.debug("Request URI : " + req.getRequestURI()); if (M_log.isDebugEnabled()) M_log.debug("Context path : " + req.getContextPath()); if (M_log.isDebugEnabled()) M_log.debug("Servlet path : " + req.getServletPath()); if (M_log.isDebugEnabled()) M_log.debug("User principal : " + req.getUserPrincipal()); if (M_log.isDebugEnabled()) M_log.debug("Headers : "); Enumeration headers = req.getHeaderNames(); while (headers.hasMoreElements()) { String headerName = (String) headers.nextElement(); System.out.print(headerName + " : "); if (M_log.isDebugEnabled()) M_log.debug(req.getHeader(headerName)); } }