Sets instance variables. @param config a ServletConfig object containing the servlet's configuration and initialization parameters @exception ServletException if an exception has occurred that interferes with the servlet's normal operation
(ServletConfig config)
| 301 | * @exception ServletException if an exception has occurred that interferes with the servlet's normal operation |
| 302 | */ |
| 303 | @Override |
| 304 | public void init(ServletConfig config) throws ServletException { |
| 305 | |
| 306 | super.init(config); |
| 307 | |
| 308 | // Set our properties from the initialization parameters |
| 309 | cgiPathPrefix = getServletConfig().getInitParameter("cgiPathPrefix"); |
| 310 | boolean passShellEnvironment = |
| 311 | Boolean.parseBoolean(getServletConfig().getInitParameter("passShellEnvironment")); |
| 312 | |
| 313 | if (passShellEnvironment) { |
| 314 | shellEnv.putAll(System.getenv()); |
| 315 | } |
| 316 | |
| 317 | Enumeration<String> e = config.getInitParameterNames(); |
| 318 | while (e.hasMoreElements()) { |
| 319 | String initParamName = e.nextElement(); |
| 320 | if (initParamName.startsWith("environment-variable-")) { |
| 321 | if (initParamName.length() == 21) { |
| 322 | throw new ServletException(sm.getString("cgiServlet.emptyEnvVarName")); |
| 323 | } |
| 324 | shellEnv.put(initParamName.substring(21), config.getInitParameter(initParamName)); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | if (getServletConfig().getInitParameter("executable") != null) { |
| 329 | cgiExecutable = getServletConfig().getInitParameter("executable"); |
| 330 | } |
| 331 | |
| 332 | if (getServletConfig().getInitParameter("executable-arg-1") != null) { |
| 333 | List<String> args = new ArrayList<>(); |
| 334 | for (int i = 1;; i++) { |
| 335 | String arg = getServletConfig().getInitParameter("executable-arg-" + i); |
| 336 | if (arg == null) { |
| 337 | break; |
| 338 | } |
| 339 | args.add(arg); |
| 340 | } |
| 341 | cgiExecutableArgs = args; |
| 342 | } |
| 343 | |
| 344 | if (getServletConfig().getInitParameter("parameterEncoding") != null) { |
| 345 | parameterEncoding = getServletConfig().getInitParameter("parameterEncoding"); |
| 346 | } |
| 347 | |
| 348 | if (getServletConfig().getInitParameter("stderrTimeout") != null) { |
| 349 | stderrTimeout = Long.parseLong(getServletConfig().getInitParameter("stderrTimeout")); |
| 350 | } |
| 351 | |
| 352 | if (getServletConfig().getInitParameter("envHttpHeaders") != null) { |
| 353 | envHttpHeadersPattern = Pattern.compile(getServletConfig().getInitParameter("envHttpHeaders")); |
| 354 | } |
| 355 | |
| 356 | if (getServletConfig().getInitParameter("enableCmdLineArguments") != null) { |
| 357 | enableCmdLineArguments = Boolean.parseBoolean(config.getInitParameter("enableCmdLineArguments")); |
| 358 | } |
| 359 | |
| 360 | if (getServletConfig().getInitParameter("cgiMethods") != null) { |
nothing calls this directly
no test coverage detected