Date: 2004-04-29T09:45:40 Editor: 131.191.40.91 <> Wiki: Apache Struts Wiki Page: StrutsCatalogEschewUrlForProtocol URL: http://wiki.apache.org/struts/StrutsCatalogEschewUrlForProtocol
no comment Change Log: ------------------------------------------------------------------------------ @@ -79,44 +79,41 @@ Here are the image constants: {{{ -public class InitResponse { - private static Log log = LogFactory.getLog(InitResponse.class); - public InitResponse() { +public class ImageConstant { + private ImageConstant() { } + // Basic resource identifiers for request parameters. + public static final String TYPE = "file_type"; + public static final String NAME = "file_name"; - public String init(HttpServletRequest request, - HttpServletResponse response) { - String fileType = (request.getParameter(ImageConstant.TYPE)).intern(); - String fileName = request.getParameter(ImageConstant.NAME); - String contentType = null; - String file = null; - if (fileType == ImageConstant.JPEG_FILE) { - contentType = ImageConstant.JPEG_CONTENT; - file = ImageConstant.JPEG_LOCATION; - } - else if (fileType == ImageConstant.FLASH_FILE) { - contentType = ImageConstant.FLASH_CONTENT; - file = ImageConstant.FLASH_LOCATION; - } - else if (fileType == ImageConstant.GIF_FILE) { - contentType = ImageConstant.GIF_CONTENT; - file = ImageConstant.GIF_LOCATION; - } - else if (fileType == ImageConstant.TEXT_FILE || fileType == ImageConstant.CSS_FILE) { - contentType = ImageConstant.TEXT_CONTENT; - file = ImageConstant.TEXT_LOCATION; - } - else if (fileType == ImageConstant.HTML_FILE) { - contentType = ImageConstant.HTML_CONTENT; - file = ImageConstant.HTML_LOCATION; - } - else if (fileType == ImageConstant.APPLET_FILE) { - contentType = ImageConstant.APPLET_CONTENT; - file = ImageConstant.APPLET_LOCATION; - } - response.setContentType(contentType); - return Classpath.WEB_INF + file + fileName; - } + // Content types + public static final String HTML_CONTENT = "text/html"; + public static final String TEXT_CONTENT = "text/plain"; + public static final String GIF_CONTENT = "image/gif"; + public static final String JPEG_CONTENT = "image/jpeg"; + public static final String FLASH_CONTENT = "application/x-shockwave-flash"; + public static final String APPLET_CONTENT = "application/x-java-applet"; + + // File types + public static final String CSS_FILE = "css"; + public static final String HTML_FILE = "html"; + public static final String TEXT_FILE = "text"; + public static final String GIF_FILE = "gif"; + public static final String JPEG_FILE = "jpeg"; + public static final String FLASH_FILE = "flash"; + public static final String APPLET_FILE = "applet"; + + // Utility constants for file locations + private static final String VIEW_PATH = ("resource" + File.separator); + private static final String APPLET_PATH = ("classes" + File.separator + "com" + File.separator + "crackwillow" + File.separator); + + // File file locations + public static final String HTML_LOCATION = (VIEW_PATH + "html" + File.separator); + public static final String TEXT_LOCATION = (VIEW_PATH + "text" + File.separator); + public static final String GIF_LOCATION = (VIEW_PATH + "gif" + File.separator); + public static final String JPEG_LOCATION = (VIEW_PATH + "jpeg" + File.separator); + public static final String FLASH_LOCATION = (VIEW_PATH + "flash" + File.separator); + public static final String APPLET_LOCATION = (APPLET_PATH + "applet" + File.separator); } }}} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]