List of usage examples for javax.servlet.http HttpServletRequest getCharacterEncoding
public String getCharacterEncoding();
From source file:org.geowebcache.service.ve.VEConverter.java
public ConveyorTile getConveyor(HttpServletRequest request, HttpServletResponse response) throws ServiceException { Map<String, String[]> params = request.getParameterMap(); String layerId = super.getLayersParameter(request); String encoding = request.getCharacterEncoding(); String strQuadKey = ServletUtils.stringFromMap(params, encoding, "quadkey"); String strFormat = ServletUtils.stringFromMap(params, encoding, "format"); String strCached = ServletUtils.stringFromMap(params, encoding, "cached"); String strMetaTiled = ServletUtils.stringFromMap(params, encoding, "metatiled"); long[] gridLoc = VEConverter.convert(strQuadKey); MimeType mimeType = null;/* w ww .j a v a 2s.c o m*/ if (strFormat != null) { try { mimeType = MimeType.createFromFormat(strFormat); } catch (MimeException me) { throw new ServiceException("Unable to determined requested format, " + strFormat); } } ConveyorTile ret = new ConveyorTile(sb, layerId, gsb.WORLD_EPSG3857.getName(), gridLoc, mimeType, null, request, response); if (strCached != null && !Boolean.parseBoolean(strCached)) { ret.setRequestHandler(ConveyorTile.RequestHandler.SERVICE); if (strMetaTiled != null && !Boolean.parseBoolean(strMetaTiled)) { ret.setHint("not_cached,not_metatiled"); } else { ret.setHint("not_cached"); } } return ret; }
From source file:net.fenyo.mail4hotspot.web.BrowserServlet.java
@Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException { // debug informations log.debug("doGet"); log.debug("context path: " + request.getContextPath()); log.debug("character encoding: " + request.getCharacterEncoding()); log.debug("content length: " + request.getContentLength()); log.debug("content type: " + request.getContentType()); log.debug("local addr: " + request.getLocalAddr()); log.debug("local name: " + request.getLocalName()); log.debug("local port: " + request.getLocalPort()); log.debug("method: " + request.getMethod()); log.debug("path info: " + request.getPathInfo()); log.debug("path translated: " + request.getPathTranslated()); log.debug("protocol: " + request.getProtocol()); log.debug("query string: " + request.getQueryString()); log.debug("requested session id: " + request.getRequestedSessionId()); log.debug("Host header: " + request.getServerName()); log.debug("servlet path: " + request.getServletPath()); log.debug("request URI: " + request.getRequestURI()); @SuppressWarnings("unchecked") final Enumeration<String> header_names = request.getHeaderNames(); while (header_names.hasMoreElements()) { final String header_name = header_names.nextElement(); log.debug("header name: " + header_name); @SuppressWarnings("unchecked") final Enumeration<String> header_values = request.getHeaders(header_name); while (header_values.hasMoreElements()) log.debug(" " + header_name + " => " + header_values.nextElement()); }/*ww w . j a v a 2 s . co m*/ if (request.getCookies() != null) for (Cookie cookie : request.getCookies()) { log.debug("cookie:"); log.debug("cookie comment: " + cookie.getComment()); log.debug("cookie domain: " + cookie.getDomain()); log.debug("cookie max age: " + cookie.getMaxAge()); log.debug("cookie name: " + cookie.getName()); log.debug("cookie path: " + cookie.getPath()); log.debug("cookie value: " + cookie.getValue()); log.debug("cookie version: " + cookie.getVersion()); log.debug("cookie secure: " + cookie.getSecure()); } @SuppressWarnings("unchecked") final Enumeration<String> parameter_names = request.getParameterNames(); while (parameter_names.hasMoreElements()) { final String parameter_name = parameter_names.nextElement(); log.debug("parameter name: " + parameter_name); final String[] parameter_values = request.getParameterValues(parameter_name); for (final String parameter_value : parameter_values) log.debug(" " + parameter_name + " => " + parameter_value); } // parse request String target_scheme = null; String target_host; int target_port; // request.getPathInfo() is url decoded final String[] path_info_parts = request.getPathInfo().split("/"); if (path_info_parts.length >= 2) target_scheme = path_info_parts[1]; if (path_info_parts.length >= 3) { target_host = path_info_parts[2]; try { if (path_info_parts.length >= 4) target_port = new Integer(path_info_parts[3]); else target_port = 80; } catch (final NumberFormatException ex) { log.warn(ex); target_port = 80; } } else { target_scheme = "http"; target_host = "www.google.com"; target_port = 80; } log.debug("remote URL: " + target_scheme + "://" + target_host + ":" + target_port); // create forwarding request final URL target_url = new URL(target_scheme + "://" + target_host + ":" + target_port); final HttpURLConnection target_connection = (HttpURLConnection) target_url.openConnection(); // be transparent for accept-language headers @SuppressWarnings("unchecked") final Enumeration<String> accepted_languages = request.getHeaders("accept-language"); while (accepted_languages.hasMoreElements()) target_connection.setRequestProperty("Accept-Language", accepted_languages.nextElement()); // be transparent for accepted headers @SuppressWarnings("unchecked") final Enumeration<String> accepted_content = request.getHeaders("accept"); while (accepted_content.hasMoreElements()) target_connection.setRequestProperty("Accept", accepted_content.nextElement()); }
From source file:com.bluexml.side.Framework.alfresco.languagepicker.MyWebScriptServlet.java
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { if (logger.isDebugEnabled()) logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); if (req.getCharacterEncoding() == null) { req.setCharacterEncoding("UTF-8"); }// ww w .j a va 2s .c o m setUserLanguage(req); try { WebScriptServletRuntime runtime = new WebScriptServletRuntime(container, authenticatorFactory, req, res, serverProperties); runtime.executeScript(); } finally { // clear threadlocal I18NUtil.setLocale(null); } }
From source file:org.deegree.client.core.filter.InputFileWrapper.java
@SuppressWarnings("unchecked") public InputFileWrapper(HttpServletRequest request) throws ServletException { super(request); try {/*w w w .j a v a 2s. c o m*/ ServletFileUpload upload = new ServletFileUpload(); DiskFileItemFactory factory = new DiskFileItemFactory(); upload.setFileItemFactory(factory); String encoding = request.getCharacterEncoding(); List<FileItem> fileItems = upload.parseRequest(request); formParameters = new HashMap<String, String[]>(); for (int i = 0; i < fileItems.size(); i++) { FileItem item = fileItems.get(i); if (item.isFormField()) { String[] values; String v; if (encoding != null) { v = item.getString(encoding); } else { v = item.getString(); } if (formParameters.containsKey(item.getFieldName())) { String[] strings = formParameters.get(item.getFieldName()); values = new String[strings.length + 1]; for (int j = 0; j < strings.length; j++) { values[j] = strings[j]; } values[strings.length] = v; } else { values = new String[] { v }; } formParameters.put(item.getFieldName(), values); } else if (item.getName() != null && item.getName().length() > 0 && item.getSize() > 0) { request.setAttribute(item.getFieldName(), item); } } } catch (FileUploadException fe) { ServletException servletEx = new ServletException(); servletEx.initCause(fe); throw servletEx; } catch (UnsupportedEncodingException e) { ServletException servletEx = new ServletException(); servletEx.initCause(e); throw servletEx; } }
From source file:org.entermedia.upload.FileUpload.java
/** * @param inContext//from w w w . j ava 2 s. com * @return */ public UploadRequest parseArguments(WebPageRequest inContext) throws OpenEditException { final UploadRequest upload = new UploadRequest(); upload.setPageManager(getPageManager()); upload.setRoot(getRoot()); //upload.setProperties(inContext.getParameterMap()); if (inContext.getRequest() == null) //used in unit tests { return upload; } String type = inContext.getRequest().getContentType(); if (type == null || !type.startsWith("multipart")) { addAlreadyUploaded(inContext, upload); return upload; } String uploadid = inContext.getRequestParameter("uploadid"); String catalogid = inContext.findValue("catalogid"); if (uploadid != null && catalogid != null) { upload.setUploadId(uploadid); upload.setCatalogId(catalogid); upload.setUserName(inContext.getUserName()); upload.setUploadQueueSearcher(loadQueueSearcher(catalogid)); } //Our factory will track these items as they are made. Each time some data comes in look over all the files and update the size FileItemFactory factory = (FileItemFactory) inContext.getPageValue("uploadfilefactory"); if (factory == null) { DiskFileItemFactory dfactory = new DiskFileItemFactory(); // { // public org.apache.commons.fileupload.FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName) // { // if( !isFormField ) // { // upload.track(fieldName, contentType, isFormField, fileName); // } // return super.createItem(fieldName, contentType, isFormField, fileName); // }; // } factory = dfactory; } ServletFileUpload uploadreader = new ServletFileUpload(factory); //upload.setSizeThreshold(BUFFER_SIZE); if (uploadid != null) { uploadreader.setProgressListener(upload); } HttpServletRequest req = inContext.getRequest(); String encode = req.getCharacterEncoding(); if (encode == null) { //log.info("Encoding not set."); encode = "UTF-8"; } //log.info("Encoding is set to " + encode); uploadreader.setHeaderEncoding(encode); //upload.setHeaderEncoding() //Content-Transfer-Encoding: binary //upload.setRepositoryPath(repository.pathToFile("admin uploadreader.setSizeMax(-1); try { readParameters(inContext, uploadreader, upload, encode); } catch (UnsupportedEncodingException e) { throw new OpenEditException(e); } if (uploadid != null) { expireOldUploads(catalogid); } return upload; }
From source file:com.aspectran.web.activity.request.multipart.MultipartFormDataParser.java
/** * Creates a RequestContext needed by Jakarta Commons Upload. * //from ww w .j a v a 2s. c o m * @param req the HTTP request. * @return a new request context. */ private RequestContext createRequestContext(final HttpServletRequest req) { return new RequestContext() { @Override public String getCharacterEncoding() { return req.getCharacterEncoding(); } @Override public String getContentType() { return req.getContentType(); } @Override @Deprecated public int getContentLength() { return req.getContentLength(); } @Override public InputStream getInputStream() throws IOException { return req.getInputStream(); } }; }
From source file:bijian.util.upload.MyMultiPartRequest.java
/** * Creates a RequestContext needed by Jakarta Commons Upload. * * @param req the request./*from w w w .j av a 2 s .c o m*/ * @return a new request context. */ private RequestContext createRequestContext(final HttpServletRequest req) { return new RequestContext() { public String getCharacterEncoding() { return req.getCharacterEncoding(); } public String getContentType() { return req.getContentType(); } public int getContentLength() { return req.getContentLength(); } public InputStream getInputStream() throws IOException { InputStream in = req.getInputStream(); if (in == null) { throw new IOException("Missing content in the request"); } return req.getInputStream(); } }; }
From source file:org.soybeanMilk.web.servlet.DispatchServlet.java
/** * ?WEB//from w ww . j av a 2 s .c o m * @param request * @param response * @throws ServletException * @throws IOException */ protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) request.setCharacterEncoding(getEncoding()); String exeName = getRequestExecutableName(request, response); if (log.isDebugEnabled()) log.debug("processing request " + SbmUtils.toString(exeName)); WebObjectSource webObjSource = getWebObjectSourceFactory().create(request, response, getServletContext()); try { getWebExecutor().execute(exeName, webObjSource); } catch (ExecutableNotFoundException e) { handleExecutableNotFound(exeName, webObjSource); } catch (ExecuteException e) { handleExecuteException(e, exeName, webObjSource); } }
From source file:com.liusoft.dlog4j.servlet.DLOG_ActionServlet.java
/** * ???/* w ww .j a va 2 s . com*/ * @param req * @param res * @throws ServletException * @throws IOException * @see org.apache.struts.action.ActionServlet#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ protected void process(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { HttpServletRequest request; if (RequestUtils.isMultipart(req)) { //??? request = req; request.setCharacterEncoding(encoding); } else { //?? String enc = req.getCharacterEncoding(); if (req instanceof RequestProxy) request = req; else if (encoding.equalsIgnoreCase(enc)) request = req; else request = new RequestProxy(req, encoding); } super.process(request, res); }
From source file:org.springframework.extensions.webscripts.servlet.WebScriptServlet.java
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { if (logger.isDebugEnabled()) logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); if (req.getCharacterEncoding() == null) { req.setCharacterEncoding("UTF-8"); }//from w ww.j a v a 2 s. co m setLanguageFromRequestHeader(req); try { WebScriptServletRuntime runtime = new WebScriptServletRuntime(container, authenticatorFactory, req, res, serverProperties); if (req.getMethod().equals(HttpMethod.OPTIONS.name())) { // respond to OPTIONS request with list of support methods for the WebScript String allow = HttpMethod.OPTIONS.name(); for (HttpMethod supportedMethod : runtime.getSupportedMethods()) { allow += ", " + supportedMethod.name(); } res.setHeader("Allow", allow); } else { // anything else, execute the script method runtime.executeScript(); } } finally { // clear threadlocal I18NUtil.setLocale(null); } }