String filenameExt = filename + ext;
if (DEBUG) System.err.println("DEBUG: filename "+filename); String filenameExt = filename + ext;
	private String generate(HttpServletRequest req,							Map<String,String> macros,							String type)	throws IOException {		String commentStart = "/* ";		String commentContinue = " * ";		String commentEnd = " */";		if (type.equals(T_HTML)) {			commentStart = "<!-- ";			commentContinue = " - ";			commentEnd = " -->";		}		// create data buffers		CharArrayWriter cout = new CharArrayWriter(4096 << 2); // 16K buffer to start		PrintWriter out = new PrintWriter(cout);		// get data		String skin = getSkin(req);		out.println(commentStart);		for (String mname : macros.keySet()) {			String mvalue = macros.get(mname);			out.print(commentContinue);			out.println("#define "+mname+" "+mvalue);		}		out.println(commentEnd);		out.println();		String uri = getRequestURI(req);		String filenames = uri;		String ext = "."+type;		int slash = uri.lastIndexOf('/');		if (slash != -1) {			filenames = uri.substring(slash + 1);		}		int dot = filenames.lastIndexOf('.');		if (dot != -1) {			ext = filenames.substring(dot);			filenames = filenames.substring(0, dot);		}		ServletContext context = getServletContext();		String fileDirname = context.getRealPath("/"+type);		File fileDir = new File(fileDirname);		String skinDirname = context.getRealPath("/skins/" + skin);		File skinDir = new File(skinDirname);		File manifestFile = new File(skinDir, skin + SKIN_MANIFEST_EXT);		// load manifest		Manifest manifest = new Manifest(manifestFile, macros);		// process input files		StringTokenizer tokenizer = new StringTokenizer(filenames, ",");		while (tokenizer.hasMoreTokens()) {			String filename = tokenizer.nextToken();			String filenameExt = filename + ext;			List<File> files = new LinkedList<File>();			if (filename.equals(N_SKIN)) {				files.addAll(manifest.getFiles(type));			}			else {				File file = new File(skinDir, filenameExt);				if (!file.exists()) {					file = new File(fileDir, filenameExt);				}				files.add(file);			}			for (File file : files) {				if (!file.exists()) {					out.print(commentStart);					out.print("Error: file doesn't exist - "+file);					out.println(commentEnd);					out.println();					continue;				}				preprocess(file, cout, macros, manifest,							commentStart, commentContinue, commentEnd);			}		}		// return data		return cout.toString();	}