Code example for URLConnection

Methods: getContentLength

    public long getFileSize(String path, boolean virtual) throws IOException {
        long fileSize = -1;
        try { 
            URLConnection urlConnection = getURLConnection(path, virtual);
            fileSize = urlConnection.getContentLength();
        } catch (IOException e) {
            // Ignore this. It will always fail for non-file based includes 
        return fileSize;
    //We are making lots of unnecessary copies of the included data here. If 
    //someone ever complains that this is slow, we should connect the included 
    // stream to the print writer that SSICommand uses. 
    public String getFileText(String originalPath, boolean virtual)
            throws IOException { 
        try { 
            ServletContextAndPath csAndP = getServletContextAndPath(