随笔-46  评论-64  文章-2  trackbacks-0
  2008年8月19日
     摘要: 废话不多说,先看看我们最终达到的效果.  源码下载在文章最后。Style1:Style2:上面的tag cloud实现思想如下:1. Server端提供Tag的相关信息,包括TagName,Posts等,使用JSON格式传输数据    这个例子中,我使用Servlet,使用json-lib将Bean转成JSON字符串。当然Tag的相关信息这里只是演示,真实环境中可能就需要从数据库取出来再处理了。 ...  阅读全文
posted @ 2008-09-28 16:10 jht 阅读(3129) | 评论 (3)编辑 收藏
1. response.setHeader("Cache-Control","no-cache");

This is used to prevent the browser from caching your dynamic content generated by a JSP or Servlet.

You set this attribute in the HTTP header of the response object which would tell the browser not to cache this content. So everytime you request the page again, the browser would make a new request, instead of showing you a cached page.

2.使用服务器端控制AJAX页面缓存:
    response.setHeader( "Pragma", "no-cache" );
    response.addHeader( "Cache-Control", "must-revalidate" );
    response.addHeader( "Cache-Control", "no-cache" );
    response.addHeader( "Cache-Control", "no-store" );
    response.setDateHeader("Expires", 0);
单纯的使用 xmlhttp.setRequestHeader("Cache-Control","no-cache")无效。

3.Cache-Control头域
  Cache-Control指定请求和响应遵循的缓存机制。在请求消息或响应消息中设置Cache-Control并不会修改另一个消息处理过程中的缓存处理过程。请求时的缓存指令包括no-cache、no-store、max-age、max-stale、min-fresh、only-if-cached,响应消息中的指令包括public、private、no-cache、no-store、no-transform、must-revalidate、proxy-revalidate、max-age。各个消息中的指令含义如下:
  Public指示响应可被任何缓存区缓存。
  Private指示对于单个用户的整个或部分响应消息,不能被共享缓存处理。这允许服务器仅仅描述当用户的部分响应消息,此响应消息对于其他用户的请求无效。
  no-cache指示请求或响应消息不能缓存
  no-store用于防止重要的信息被无意的发布。在请求消息中发送将使得请求和响应消息都不使用缓存。
  max-age指示客户机可以接收生存期不大于指定时间(以秒为单位)的响应。
  min-fresh指示客户机可以接收响应时间小于当前时间加上指定时间的响应。
  max-stale指示客户机可以接收超出超时期间的响应消息。如果指定max-stale消息的值,那么客户机可以接收超出超时期指定值之内的响应消息。

Read more:
   http://www.jiehoo.com/browser-cache-problem.htm (作者: Cherami 原载: 浏览器缓存)
   再论怎么有效利用浏览器缓存之怎么避免浏览器缓存静态文件
   HTTP协议header头域- PetitPrince - 博客园
posted @ 2008-09-27 10:23 jht 阅读(16549) | 评论 (3)编辑 收藏
< link id = " css "  rel = StyleSheet type = " text/css "  href = " ./button.css "   />

< script type = " text/javascript " >
 
var  cssArray  =   new  Array( " button.css " , " button1.css " , " button2.css " , " button3.css " , " button4.css " , " button5.css " , " button6.css " );
 
var  index  =   0 ;
 
function  changeCssFile()
 
{
  
var  css  =  document.getElementById( " css " );
  index
++ ;
  
if (index < cssArray.length)
  
{
   css.href 
=  cssArray[index];
  }

  
else
  
{
   index 
= 0 ;
   css.href 
=  cssArray[index];
  }

 }

</ script >

  < class ="button"  href ="#"  onclick ="changeCssFile()" >
  
< span  id ="buttonText" > Change another style </ span >
 
</ a >
posted @ 2008-09-25 12:26 jht 阅读(743) | 评论 (0)编辑 收藏
A:浏览器问题,可能会把透明区域显示成有灰度的区域,解决办法,转成gif格式吧,支持比较好

see: GIF or PNG? - Quality Web Tips
posted @ 2008-09-24 23:02 jht 阅读(1163) | 评论 (1)编辑 收藏
比如说下面的这个header.jsp中有中文,那么包含这个文件的网页可能就会出现乱码
<jsp:include page="header.jsp"></jsp:include>

解决办法是在header.jsp里加上下面这段话:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
posted @ 2008-09-23 12:46 jht 阅读(434) | 评论 (0)编辑 收藏
     摘要: log4j 支持运行时修改日志的相关配置,看了一下他的source code, 用FileWatchdog这个类来做的,代码也很简单,通过循环在一定时间间隔读取配置文件,如果文件变更,调用一个doOnChange()方法。如果自己要做一个支持运行时修改配置的系统可参考上面的做法。下面是一段支持运行时修改配置的系统Prototype代码,和log4j的做法稍有不同,使用Observer模式,使其更加...  阅读全文
posted @ 2008-09-04 14:49 jht 阅读(1288) | 评论 (0)编辑 收藏

可以用下面这个方法来做到

import  org.apache.log4j.Logger;
import  org.apache.log4j.PropertyConfigurator;

public   class  DemoRunTimeChangeLog4J  {

 
private   static   final  Logger logger  =  Logger.getLogger(DemoRunTimeChangeLog4J. class );

 
public   static   void  main(String[] args)  {
  PropertyConfigurator.configureAndWatch(
" src/log4j.configureAndWatch " , 60000 );
  
  
while  ( true {
   
if  (logger.isDebugEnabled())  {
    logger.debug(
" DEBUG MESSAGE " );
   }


   logger.info(
" Info Message " );

   
try   {
    Thread.sleep(
5000 );
   }
  catch  (InterruptedException e)  {
   }

  }

 }

}


posted @ 2008-09-03 17:35 jht 阅读(609) | 评论 (0)编辑 收藏
自定义TagLib的时候碰到这个错误,原因是编辑tld文件的时候没有使用DTD或者Schema文件验证,拼写错误导致最终报这个错误消息

如果遇到同样问题的同学,不妨检查一下自己的tld文件对不对。

BTW: tld类的异常需要处理好
posted @ 2008-08-19 15:53 jht 阅读(7658) | 评论 (1)编辑 收藏