Java Code Examples for org.apache.catalina.connector.Connector#setUseBodyEncodingForURI()
The following examples show how to use
org.apache.catalina.connector.Connector#setUseBodyEncodingForURI() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TomcatServer.java From athena-rest with Apache License 2.0 | 4 votes |
private void initTomcat() { serverStatus = ServerStatus.STARTING; tomcat = new Tomcat(); tomcat.setPort(port); // Changed it to use NIO due to poor performance in burdon test Connector connector = new Connector(Utils.getStringProperty(properties, "web.connectorProtocol")); connector.setURIEncoding("UTF-8"); connector.setPort(port); connector.setUseBodyEncodingForURI(true); connector.setAsyncTimeout(Utils.getIntegerValue(properties, WEB_ASYNC_TIMEOUT, DEFAULT_ASYNC_TIMEOUT)); connector.setAttribute("minProcessors", Utils.getIntegerValue( properties, WEB_MIN_PROCESSORS, DEFAULT_MIN_PROCESSORS)); connector.setAttribute("maxProcessors", Utils.getIntegerValue( properties, WEB_MAX_PROCESSORS, DEFAULT_MAX_PROCESSORS)); connector.setAttribute("acceptCount", Utils.getIntegerValue(properties, WEB_ACCEPT_COUNT, DEFAULT_ACCEPT_COUNT)); connector.setAttribute("minSpareThreads", Utils.getIntegerValue( properties, WEB_MIN_SPARE_THREADS, DEFAULT_MIN_SPARE_THREADS)); connector.setAttribute("maxThreads", Utils.getIntegerValue(properties, WEB_MAX_THREADS, DEFAULT_MAX_THREADS)); connector.setRedirectPort(Utils.getIntegerValue(properties, WEB_REDIRECT_PORT, DEFAULT_WEB_REDIRECT_PORT)); if (this.minThreads != -1 && this.maxThreads != -1) { connector.setAttribute("minThreads", minThreads); connector.setAttribute("maxThreads", maxThreads); } Service tomcatService = tomcat.getService(); tomcatService.addConnector(connector); tomcat.setConnector(connector); Context context = null; try { context = tomcat.addWebapp(contextPath, new File(webappPath).getAbsolutePath()); } catch (ServletException e) { log.error("Failed to add webapp + " + webappPath, e); exit(); } context.setLoader(new WebappLoader(Thread.currentThread() .getContextClassLoader())); String extraResourcePaths = properties .getProperty(WEB_EXTRA_RESOURCE_PATHS); if (!StringUtils.isBlank(extraResourcePaths)) { VirtualDirContext virtualDirContext = new VirtualDirContext(); virtualDirContext.setExtraResourcePaths(extraResourcePaths); context.setResources(virtualDirContext); } StandardServer server = (StandardServer) tomcat.getServer(); AprLifecycleListener listener = new AprLifecycleListener(); server.addLifecycleListener(listener); }