/* ------------------------------------------------------------
3736
public boolean checkSecurityConstraints(String pathInContext,
                                            HttpRequest request,
                                            HttpResponse response)
            throws HttpException, IOException
    {
        if (!super.checkSecurityConstraints(pathInContext,request,response) ||
            ! jSecurityCheck(pathInContext,request,response))
            return false;
        
        return true;
    }
877972
public void init()
    {
        this.leading = 0;
        while (this.leading < this.value.length() && this.value.charAt(this.leading) == ' ')
        {
            this.leading++;
        }

        if (this.leading == this.value.length())
        {
            this.setEmpty();
        }
        else
        {
            this.isEmpty = false;
            this.trailing = 0;
            while (this.value.charAt(this.value.length() - this.trailing - 1) == ' ')
            {
                this.trailing++;
            }
        }
    }
485647
private void _ws() throws
      IOException
  {
    builder.type = Type.S;
    // no need to preserve exact whitespace
    // but append an S char to keep the token
    // contract of always having a value
    builder.append(' ');
    reader.forward(NOT_WHITESPACE);

    if (debug)
    {
      int nxt = reader.peek();
      checkArgument(WHITESPACE.matches((char) reader.curChar));
      if (nxt > -1)
      {
        checkArgument(NOT_WHITESPACE.matches((char) nxt));
      }
    }
  }
1371550
@Override
  protected void doPost(final HttpServletRequest req, final HttpServletResponse resp)
      throws ServletException, IOException {

    final boolean noCache = null != req && Boolean.valueOf(req.getParameter(noCacheParamName));

    if (noCache || System.currentTimeMillis() - lastRefreshedTime > cacheTimeInMilliseconds) {
      this.populateStatistics(noCache);
    }

    JSONUtils.toJSON(cachedstats, resp.getOutputStream(), true);
  }
182907
public void doInitialKey()
    {
        FileListener nextListener = (FileListener)this.getNextEnabledListener();
        if (nextListener != null)
        {
            boolean bOldState = nextListener.setEnabledListener(false);  // Don't allow it to be called again
            nextListener.doInitialKey();
            nextListener.setEnabledListener(bOldState);
        }
        else if (this.getOwner() != null)
            this.getOwner().doInitialKey();
    }
319643
public static void main(String[] pArgs) throws IOException {
        // params:
        int timeout = 0;
        boolean followRedirects = true;
        boolean debugHeaders = false;
        String requestPropertiesFile = null;
        String requestHeaders = null;
        String postData = null;
        File putData = null;
        int argIdx = 0;
        boolean errArgs = false;
        boolean writeToFile = false;
        boolean writeToStdOut = false;
        String outFileName = null;

        while ((argIdx < pArgs.length) && (pArgs[argIdx].charAt(0) == '-') && (pArgs[argIdx].length() >= 2)) {
            if ((pArgs[argIdx].charAt(1) == 't') || pArgs[argIdx].equals("--timeout")) {
                argIdx++;
                try {
                    timeout = Integer.parseInt(pArgs[argIdx++]);
                }
                catch (NumberFormatException nfe) {
                    errArgs = true;
                    break;
                }
            }
            else if ((pArgs[argIdx].charAt(1) == 'd') || pArgs[argIdx].equals("--debugheaders")) {
                debugHeaders = true;
                argIdx++;
            }
            else if ((pArgs[argIdx].charAt(1) == 'n') || pArgs[argIdx].equals("--nofollowredirects")) {
                followRedirects = false;
                argIdx++;
            }
            else if ((pArgs[argIdx].charAt(1) == 'r') || pArgs[argIdx].equals("--requestproperties")) {
                argIdx++;
                requestPropertiesFile = pArgs[argIdx++];
            }
            else if ((pArgs[argIdx].charAt(1) == 'p') || pArgs[argIdx].equals("--postdata")) {
                argIdx++;
                postData = pArgs[argIdx++];
            }
            else if ((pArgs[argIdx].charAt(1) == 'u') || pArgs[argIdx].equals("--putdata")) {
                argIdx++;
                putData = new File(pArgs[argIdx++]);
                if (!putData.exists()) {
                    errArgs = true;
                    break;
                }
            }
            else if ((pArgs[argIdx].charAt(1) == 'h') || pArgs[argIdx].equals("--header")) {
                argIdx++;
                requestHeaders = pArgs[argIdx++];
            }
            else if ((pArgs[argIdx].charAt(1) == 'f') || pArgs[argIdx].equals("--file")) {
                argIdx++;
                writeToFile = true;

                // Get optional file name
                if (!((argIdx >= (pArgs.length - 1)) || (pArgs[argIdx].charAt(0) == '-'))) {
                    outFileName = pArgs[argIdx++];
                }
            }
            else if ((pArgs[argIdx].charAt(1) == 'o') || pArgs[argIdx].equals("--output")) {
                argIdx++;
                writeToStdOut = true;
            }
            else {
                System.err.println("Unknown option \"" + pArgs[argIdx++] + "\"");
            }
        }
        if (errArgs || (pArgs.length < (argIdx + 1))) {
            System.err.println("Usage: java  NetUtil [-f|--file [<file name>]] [-d|--debugheaders] [-h|--header <header data>] [-p|--postdata <URL-encoded postdata>] [-u|--putdata <file name>] [-r|--requestProperties <properties file>] [-t|--timeout <miliseconds>] [-n|--nofollowredirects] fromUrl");
            System.exit(5);
        }
        String url = pArgs[argIdx/*++*/];

        // DONE ARGS
        // Get request properties
        Properties requestProperties = new Properties();

        if (requestPropertiesFile != null) {

            // Just read, no exception handling...
            requestProperties.load(new FileInputStream(new File(requestPropertiesFile)));
        }
        if (requestHeaders != null) {

            // Get request headers
            String[] headerPairs = StringUtil.toStringArray(requestHeaders, ",");

            for (String headerPair : headerPairs) {
                String[] pair = StringUtil.toStringArray(headerPair, ":");
                String key = (pair.length > 0)
                        ? pair[0].trim()
                        : null;
                String value = (pair.length > 1)
                        ? pair[1].trim()
                        : "";

                if (key != null) {
                    requestProperties.setProperty(key, value);
                }
            }
        }
        HttpURLConnection conn;

        // Create connection
        URL reqURL = getURLAndSetAuthorization(url, requestProperties);

        conn = createHttpURLConnection(reqURL, requestProperties, followRedirects, timeout);

        // POST
        if (postData != null) {
            // HTTP POST method
            conn.setRequestMethod(HTTP_POST);

            // Set entity headers
            conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            conn.setRequestProperty("Content-Length", String.valueOf(postData.length()));
            conn.setRequestProperty("Content-Encoding", "ISO-8859-1");

            // Get outputstream (this is where the connect actually happens)
            OutputStream os = conn.getOutputStream();

            System.err.println("OutputStream: " + os.getClass().getName() + "@" + System.identityHashCode(os));
            OutputStreamWriter writer = new OutputStreamWriter(os, "ISO-8859-1");

            // Write post data to the stream
            writer.write(postData);
            writer.write("\r\n");

            //writer.flush();
            writer.close();  // Does this close the underlying stream?
        }
        // PUT
        else if (putData != null) {
            // HTTP PUT method
            conn.setRequestMethod(HTTP_PUT);

            // Set entity headers
            //conn.setRequestProperty("Content-Type", "???");
            // TODO: Set Content-Type to correct type?
            // TODO: Set content-encoding? Or can binary data be sent directly?
            conn.setRequestProperty("Content-Length", String.valueOf(putData.length()));

            // Get outputstream (this is where the connect actually happens)
            OutputStream os = conn.getOutputStream();

            System.err.println("OutputStream: " + os.getClass().getName() + "@" + System.identityHashCode(os));

            // Write put data to the stream
            FileUtil.copy(new FileInputStream(putData), os);

            os.close();
        }

        //
        InputStream is;

        if (conn.getResponseCode() == 200) {

            // Connect and get stream
            is = conn.getInputStream();
        }
        else {
            is = conn.getErrorStream();
        }

        //
        if (debugHeaders) {
            System.err.println("Request (debug):");
            System.err.println(conn.getClass());
            System.err.println("Response (debug):");

            // Headerfield 0 is response code
            System.err.println(conn.getHeaderField(0));

            // Loop from 1, as headerFieldKey(0) == null...
            for (int i = 1; ; i++) {
                String key = conn.getHeaderFieldKey(i);

                // Seems to be the way to loop through them all...
                if (key == null) {
                    break;
                }
                System.err.println(key + ": " + conn.getHeaderField(key));
            }
        }

        // Create output file if specified
        OutputStream os;

        if (writeToFile) {
            if (outFileName == null) {
                outFileName = reqURL.getFile();
                if (StringUtil.isEmpty(outFileName)) {
                    outFileName = conn.getHeaderField("Location");
                    if (StringUtil.isEmpty(outFileName)) {
                        outFileName = "index";

                        // Find a suitable extension
                        // TODO: Replace with MIME-type util with MIME/file ext mapping
                        String ext = conn.getContentType();

                        if (!StringUtil.isEmpty(ext)) {
                            int idx = ext.lastIndexOf('/');

                            if (idx >= 0) {
                                ext = ext.substring(idx + 1);
                            }
                            idx = ext.indexOf(';');
                            if (idx >= 0) {
                                ext = ext.substring(0, idx);
                            }
                            outFileName += "." + ext;
                        }
                    }
                }
                int idx = outFileName.lastIndexOf('/');

                if (idx >= 0) {
                    outFileName = outFileName.substring(idx + 1);
                }
                idx = outFileName.indexOf('?');
                if (idx >= 0) {
                    outFileName = outFileName.substring(0, idx);
                }
            }
            File outFile = new File(outFileName);

            if (!outFile.createNewFile()) {
                if (outFile.exists()) {
                    System.err.println("Cannot write to file " + outFile.getAbsolutePath() + ", file allready exists.");
                }
                else {
                    System.err.println("Cannot write to file " + outFile.getAbsolutePath() + ", check write permissions.");
                }
                System.exit(5);
            }
            os = new FileOutputStream(outFile);
        }
        else if (writeToStdOut) {
            os = System.out;
        }
        else {
            os = null;
        }

        // Get data.
        if ((writeToFile || writeToStdOut) && is != null) {
            FileUtil.copy(is, os);
        }

        /*
                    Hashtable postData = new Hashtable();
                    postData.put("SearchText", "condition");

                    try {
                        InputStream in = getInputStreamHttpPost(pArgs[argIdx], postData,
                                                             props, true, 0);
                        out = new FileOutputStream(file);
                        FileUtil.copy(in, out);
                    }
                    catch (Exception e) {
                        System.err.println("Error: " + e);
                        e.printStackTrace(System.err);
                        continue;
                    }
         */
    }
583638
@SuppressWarnings("unchecked")
    public void init() throws ServletException {
	// Method re-written for PQ47469
	String servlets = getRequiredInitParameter(PARAM_SERVLET_PATHS);
	StringTokenizer sTokenizer = new StringTokenizer(servlets);
	Vector servletChainPath = new Vector();

	while (sTokenizer.hasMoreTokens() == true) {
		String path = sTokenizer.nextToken().trim();
			
		if (path.length() > 0) {
			servletChainPath.addElement(path);
		}
	}

	int chainLength = servletChainPath.size();

	if (chainLength > 0) {
		this.chainPath = new String[chainLength];
			
		for (int index = 0; index < chainLength; ++index) {
			this.chainPath[index] = (String)servletChainPath.elementAt(index);
		}
	}

    }
140491
@Override
    public void setRequestURI(byte[] uri) {

        if (null == uri || 0 == uri.length) {
            throw new IllegalArgumentException("setRequestURI: null input");
        }
        super.setFirstLineChanged();

        if ('*' == uri[0]) {
            // URI of "*" can only be one character long to be valid
            if (1 != uri.length && '?' != uri[1]) {
                String value = GenericUtils.getEnglishString(uri);
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "setRequestURI: invalid uri [" + value + "]");
                }
                throw new IllegalArgumentException("Invalid uri: " + value);
            }
        } else if ('/' != uri[0]) {
            String value = GenericUtils.getEnglishString(uri);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "setRequestURI: invalid uri [" + value + "]");
            }
            throw new IllegalArgumentException("Invalid uri: " + value);
        }

        initScheme();
        this.myURIString = null;
        this.sUrlHost = null;
        this.iUrlPort = HeaderStorage.NOTSET;
        this.myQueryBytes = null;
        this.queryParams = null;
        parseURI(uri, 0);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "setRequestURI: set URI to " + getRequestURI());
        }
    }
197041
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
            {
                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:&nbsp;").cell().right();
            table.addCell("" + request.getMethod());
            table.newRow();
            table.addHeading("getContentLength:&nbsp;").cell().right();
            table.addCell(Integer.toString(request.getContentLength()));
            table.newRow();
            table.addHeading("getContentType:&nbsp;").cell().right();
            table.addCell("" + request.getContentType());
            table.newRow();
            table.addHeading("getCharacterEncoding:&nbsp;").cell().right();
            table.addCell("" + request.getCharacterEncoding());
            table.newRow();
            table.addHeading("getRequestURI:&nbsp;").cell().right();
            table.addCell("" + request.getRequestURI());
            table.newRow();
            table.addHeading("getRequestURL:&nbsp;").cell().right();
            table.addCell("" + request.getRequestURL());
            table.newRow();
            table.addHeading("getContextPath:&nbsp;").cell().right();
            table.addCell("" + request.getContextPath());
            table.newRow();
            table.addHeading("getServletPath:&nbsp;").cell().right();
            table.addCell("" + request.getServletPath());
            table.newRow();
            table.addHeading("getPathInfo:&nbsp;").cell().right();
            table.addCell("" + request.getPathInfo());
            table.newRow();
            table.addHeading("getPathTranslated:&nbsp;").cell().right();
            table.addCell("" + request.getPathTranslated());
            table.newRow();
            table.addHeading("getQueryString:&nbsp;").cell().right();
            table.addCell("" + request.getQueryString());

            table.newRow();
            table.addHeading("getProtocol:&nbsp;").cell().right();
            table.addCell("" + request.getProtocol());
            table.newRow();
            table.addHeading("getScheme:&nbsp;").cell().right();
            table.addCell("" + request.getScheme());
            table.newRow();
            table.addHeading("getServerName:&nbsp;").cell().right();
            table.addCell("" + request.getServerName());
            table.newRow();
            table.addHeading("getServerPort:&nbsp;").cell().right();
            table.addCell("" + Integer.toString(request.getServerPort()));
            table.newRow();
            table.addHeading("getLocalName:&nbsp;").cell().right();
            table.addCell("" + request.getLocalName());
            table.newRow();
            table.addHeading("getLocalAddr:&nbsp;").cell().right();
            table.addCell("" + request.getLocalAddr());
            table.newRow();
            table.addHeading("getLocalPort:&nbsp;").cell().right();
            table.addCell("" + Integer.toString(request.getLocalPort()));
            table.newRow();
            table.addHeading("getRemoteUser:&nbsp;").cell().right();
            table.addCell("" + request.getRemoteUser());
            table.newRow();
            table.addHeading("getRemoteAddr:&nbsp;").cell().right();
            table.addCell("" + request.getRemoteAddr());
            table.newRow();
            table.addHeading("getRemoteHost:&nbsp;").cell().right();
            table.addCell("" + request.getRemoteHost());
            table.newRow();
            table.addHeading("getRemotePort:&nbsp;").cell().right();
            table.addCell("" + request.getRemotePort());
            table.newRow();
            table.addHeading("getRequestedSessionId:&nbsp;").cell().right();
            table.addCell("" + request.getRequestedSessionId());
            table.newRow();
            table.addHeading("isSecure():&nbsp;").cell().right();
            table.addCell("" + request.isSecure());

            table.newRow();
            table.addHeading("isUserInRole(admin):&nbsp;").cell().right();
            table.addCell("" + request.isUserInRole("admin"));

            table.newRow();
            table.addHeading("getLocale:&nbsp;").cell().right();
            table.addCell("" + request.getLocale());

            Enumeration locales= request.getLocales();
            while (locales.hasMoreElements())
            {
                table.newRow();
                table.addHeading("getLocales:&nbsp;").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 + ":&nbsp;").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 + ":&nbsp;").cell().right();
                table.addCell(request.getParameter(name));
                String[] values= request.getParameterValues(name);
                if (values == null)
                {
                    table.newRow();
                    table.addHeading(name + " Values:&nbsp;").cell().right();
                    table.addCell("NULL!!!!!!!!!");
                }
                else
                    if (values.length > 1)
                    {
                        for (int i= 0; i < values.length; i++)
                        {
                            table.newRow();
                            table.addHeading(name + "[" + i + "]:&nbsp;").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() + ":&nbsp;").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 + ":&nbsp;").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 + ":&nbsp;").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 + ":&nbsp;").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 + ":&nbsp;").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 + ":&nbsp;").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():&nbsp;").cell().right();
                table.addCell("" + this.getClass().getResource(res));

                table.newRow();
                table.addHeading("this.getClass().getClassLoader():&nbsp;").cell().right();
                table.addCell("" + this.getClass().getClassLoader().getResource(res));

                table.newRow();
                table.addHeading("Thread.currentThread().getContextClassLoader():&nbsp;").cell().right();
                table.addCell("" + Thread.currentThread().getContextClassLoader().getResource(res));

                table.newRow();
                table.addHeading("getServletContext():&nbsp;").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:  DÃ¼rst<br/>");
            page.add("HTML reference: D&uuml;rst<br/>");
            page.add("Decimal (252) 8859-1: D&#252;rst<br/>");
            page.add("Hex (xFC) 8859-1: D&#xFC;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();

    }
516212
@Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Context context =
                ReadOnlyContext.getContext(Constants.HTTP_REQUEST.REST.uri,
                                           request);
        try {
            // Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload();

            // Parse the request, looking for "file"
            InputStream in = null;
            FileItemIterator iter = upload.getItemIterator(request);
            while (in == null && iter.hasNext()) {
                FileItemStream item = iter.next();
                logger.info("Got next item: isFormField={} fieldName={}", item.isFormField(), item.getFieldName());
                if (!item.isFormField() && item.getFieldName().equals("file")) {
                    in = item.openStream();
                }
            }
            if (in == null) {
                sendResponse(HttpServletResponse.SC_BAD_REQUEST,
                             "No data sent.",
                             response);
            } else {
                sendResponse(HttpServletResponse.SC_CREATED,
                             m_management.putTempStream(context, in),
                             response);
            }
        } catch (AuthzException ae) {
            throw RootException.getServletException(ae,
                                                    request,
                                                    "Upload",
                                                    EMPTY_STRING_ARRAY);
        } catch (Exception e) {
            e.printStackTrace();
            sendResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e
                    .getClass().getName()
                    + ": " + e.getMessage(), response);
        }
    }
1155837
public function init(): void
    {
        if ($this->sourcePath !== null) {
            $this->sourcePath = $this->findPath($this->sourcePath);
        }
        if ($this->basePath !== null) {
            $this->basePath = $this->findPath($this->basePath);
        }
        if ($this->baseUrl !== null) {
            $this->baseUrl = rtrim(Yii::getAlias($this->baseUrl), '/');
        }
    }
1174745
public function onBeforeWrite()
    {
        if (!$this->isInDB()) {
            $this->CreatorID = Member::currentUserID();
        }

        if (!$this->VersionNumber) {
            $versions = DataObject::get(
                'FileVersion', sprintf('"FileID" = %d', $this->FileID)
            );

            if ($versions) {
                $this->VersionNumber = $versions->Count() + 1;
            } else {
                $this->VersionNumber = 1;
            }
        }

        if (!$this->Filename) {
            $this->Filename = $this->saveCurrentVersion();
        }

        parent::onBeforeWrite();
    }
104400
public function init() {
        $this->_req = $this->getRequest()->getParam('request');
        $this->_response = $this->getRequest()->getParam('response');
    }
1358314
@Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {

        String api = request.getParameter("api");

        if (api == null || api.length() == 0) {
            response.setContentType("text/html; charset=UTF-8");
            getIndex(response.getWriter());
        } else {
            response.setContentType("text/xml; charset=UTF-8");
            getWSDL(api.toUpperCase(), request.getRequestURL()
                            .toString(), response.getWriter());
        }

        response.flushBuffer();
    }
1279378
void recycle(ServletHandler servletHandler,String pathInContext)
    {
        _servletHandler=servletHandler;
        _pathInContext=pathInContext;
        _servletPath=null;
        _pathInfo=null;
        _query=null;
        _pathTranslated=null;
        _requestedSessionId=null;
        _session=null;
        _sessionIdState=__SESSIONID_NOT_CHECKED;
        _in=null;
        _reader=null;
        _inputState=0;
        _servletHolder=null;

        if (servletHandler!=null)
            _contextPath=_servletHandler.getHttpContext().getContextPath();
        if (_contextPath!=null&&_contextPath.length()<=1)
                _contextPath="";
    }
274300
@Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
        StringBuilder cacheControl = new StringBuilder(cacheability.getValue()).append(", max-age=").append(expiration);
        if (mustRevalidate) {
            cacheControl.append(", must-revalidate");
        }

        // Set cache directives
        httpServletResponse.setHeader(HTTPCacheHeader.CACHE_CONTROL.getName(), cacheControl.toString());
        httpServletResponse.setDateHeader(HTTPCacheHeader.EXPIRES.getName(), System.currentTimeMillis() + expiration
                * 1000L);

        // Set Vary field
        if (vary != null && !vary.isEmpty()) {
            httpServletResponse.setHeader(HTTPCacheHeader.VARY.getName(), vary);
        }

        /*
         * By default, some servers (e.g. Tomcat) will set headers on any SSL content to deny caching. Omitting the
         * Pragma header takes care of user-agents implementing HTTP/1.0.
         */
        filterChain.doFilter(servletRequest, new HttpServletResponseWrapper(httpServletResponse) {
            @Override
            public void addHeader(String name, String value) {
                if (!HTTPCacheHeader.PRAGMA.getName().equalsIgnoreCase(name)) {
                    super.addHeader(name, value);
                }
            }

            @Override
            public void setHeader(String name, String value) {
                if (!HTTPCacheHeader.PRAGMA.getName().equalsIgnoreCase(name)) {
                    super.setHeader(name, value);
                }
            }
        });
    }
236169
public function _afterLoad()
    {
        $value = $this->getValue();
        /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
        /** @noinspection PhpParamsInspection */
        $this->setValue(empty($value) ? false : $this->encoder->decode($value));
        parent::_afterLoad();
    }