Welcome 布拉格

          BlogJava 首頁 聯系 聚合 管理
            6 Posts :: 13 Stories :: 15 Comments :: 0 Trackbacks

          ?<FORM id="form1" METHOD=POST ACTION="publishAction.jsp" onSubmit="return check();">
          ? 獲取apache目錄<br/>
          ? 發布css,js,img等靜態資源文件<br/>
          ?? <br/>
          ? <br/>
          ? <%String docBase = pageContext.getServletContext().getRealPath("/");%><br/>
          ? 顯示出 <%=docBase%> 文件列表<br/>
          ? <%
          ?? File f = new File(docBase);
          ? %>
          ? <table class="listTable">
          ? <tr>
          ?? <th>JSP文件</th>
          ?? <th>啟用緩存</th>
          ?? <th>緩存文件</th>
          ?? <th></th>
          ?? <th></th>
          ? </tr>
          ? <c:forEach var="filename" items="<%=f.list()%>">
          ? <c:if test="${fn:endsWith(filename, '.jsp')}">
          ?? <tr>
          ?? <td>${filename}</td>
          ?? <td>啟用</td>
          ?? <td>
          ?? <%
          ??? String fileName = (String)pageContext.findAttribute("filename");
          ??? fileName = fileName.replaceAll(".jsp","_cache.html");
          ??? if(new File(docBase+"cache"+File.separatorChar+fileName).exists()){
          ??????? out.println(fileName);
          ??? }else{
          ????????????????
          ??? }
          ?? %>
          ?? </td>
          ?? <td><a href="deleteCacheAction.jsp?page=${filename}" title="清除緩存">清除緩存</td>
          ?? <td><a href="publishAction.jsp?page=${filename}" title="重新生成">重新生成</a></td>
          ?? </tr>
          ? </c:if>
          ? </c:forEach>
          ? </table>
          ?</FORM>


          public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          ??????? //???? Pass control on to the next filter
          ??????? //
          ??????? //request.setCharacterEncoding("utf-8");
          ??????? HttpServletRequest req = (HttpServletRequest) request;
          ??????? String path = req.getServletPath();
          ??????? if ((!path.startsWith("/admin")) && path.endsWith(".jsp")&&req.getParameter("makeCache")==null) {
          ??????????? path = path.replaceAll(".jsp", "_cache.html");
          ????????????????? System.out.println(path);
          ????????????????????? System.out.println(req.getRequestURI());
          ????????????????????? System.out.println(req.getRequestURL());
          ??????????? request.getRequestDispatcher("/cache"+path).forward(request, response);
          ??????? } else {
          ??????????? chain.doFilter(request, response);
          ??????? }
          ??? }
          ??? /**
          ???? * Place this filter into service.
          ???? *
          ???? * @param filterConfig The filter configuration object
          ???? */
          ??? public void init(FilterConfig filterConfig) throws ServletException {
          ??????? this.filterConfig = filterConfig;
          ??????? this.enable = filterConfig.getInitParameter("enable");
          ??? }


          --------------------------------------------------------------------------------

          ?

          posted on 2007-09-10 16:46 Welcome 閱讀(267) 評論(0)  編輯  收藏 所屬分類: HTML\CSS
          主站蜘蛛池模板: 汕尾市| 菏泽市| 吉隆县| 柞水县| 江门市| 盱眙县| 宁明县| 兴宁市| 兴文县| 虞城县| 洞口县| 禹州市| 桐乡市| 蒙城县| 前郭尔| 仁怀市| 肥城市| 方正县| 绵竹市| 屯留县| 和静县| 新邵县| 沙雅县| 吉首市| 天气| 钦州市| 南和县| 胶南市| 夏河县| 固安县| 泉州市| 阜宁县| 周宁县| 邛崃市| 瑞丽市| 关岭| 策勒县| 南郑县| 贵定县| 伊吾县| 永善县|