DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=34000>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=34000 ------- Additional Comments From [EMAIL PROTECTED] 2005-03-15 03:59 ------- here is the GUIJsGetter servlet /* * SupportWizard 2 * * Copyright (C) 2001 ISC corp. All Rights Reserved. * * $Id: GUIJsGetter,v 1.44 2005/02/03 15:24:34 grig Exp $ */ package com.supportwizard.gui2.servlets.system; import com.supportwizard.utils.RevisionHelper; import java.io.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Category; import org.apache.log4j.Logger; /** * javascript getter * @author Grigory Danileyko */ public class GUIJsGetter extends HttpServlet { private final static String CONTENT_TYPE_VALUE = "text/javascript"; private static final String CACHE_CONTROL_KEY = "Cache-Control"; private static final String PRIVATE_CACHE_VALUE = "private"; private static final String STORING_RULES = "max-age=" + 1 + ", must- revalidate"; /** * logger instance */ private final static Category log = Logger.getInstance(GUIJsGetter.class); protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } /** * do get * @param request * @param response * @throws ServletException * @throws IOException */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final File file = getFileInfo(request); if (!file.getPath().endsWith(".js")) { log.warn(file.getPath() + " is not javascript page."); throw new ServletException("it is not a javascript page"); } else { log.warn("doGet for " + file.getPath()); if (file.exists()) { try { doContentInfo(response, file.length()); doFile(file, response); } catch (IOException e) { log.error(e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } else { log.error("the requested file " + file.getPath() + " not found"); response.sendError(HttpServletResponse.SC_NOT_FOUND); } } } private final File getFileInfo(final HttpServletRequest newRequest) { final String path = getServletContext().getRealPath (newRequest.getServletPath()); return new File(path); } protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final File file = getFileInfo(request); log.warn("doHead for " + file.getPath()); if (file.exists()) { doContentInfo(response, file.length()); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } } /** * reads the requested file and put out it to browser. * @param newFile * @param response * @throws IOException */ private static final void doFile(final File newFile, final HttpServletResponse response) throws IOException { final PrintWriter out = response.getWriter(); final BufferedReader reader = new BufferedReader(new FileReader(newFile)); try { String line; while ((line = reader.readLine()) != null) out.println(line); } finally { reader.close(); } } protected long getLastModified(final HttpServletRequest request) { final String path = getServletContext().getRealPath(request.getServletPath ()); final File file = new File(path); log.warn("getLastModified for " + path); return Math.max(RevisionHelper.getBuildDateUtc(), file.lastModified()); } private final static void doContentInfo(final HttpServletResponse response, final long newLength) { response.setContentLength((int) newLength); response.setContentType(CONTENT_TYPE_VALUE); response.setHeader(CACHE_CONTROL_KEY, PRIVATE_CACHE_VALUE); response.setHeader(CACHE_CONTROL_KEY, STORING_RULES); } } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]