Tag: filter预览模式: 普通 | 列表
08-05
19

今天的51.la全屏都是灰色的

     今天的51.la全屏都是灰色的,估计是震灾的关系。不过让我很纳闷,不可能是所有图片包括字体重做了吧?
     于是打开源码,注意有这么一句话:
BODY {
FONT-SIZE: 12px; FILTER: gray; WORD-BREAK: break-all; LINE-HEIGHT: 120%; FONT-FAMILY: 宋体
}

     FILTER元素是起着全局作用的地方。
     PS: 原来好多网站都加了。既然都加了,我也加吧...向汶川大地震遇难同胞致哀,为生者祈福。

查看更多...

Tags: filter 51.la

分类:Css&Ps | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 472
08-04
16

使用过滤器使您的 JSP 具有 HTTP 压缩功能

HTTP 压缩是指浏览器能够理解压缩过的 HTML 代码, 文本文档等, 从而减少网络传输流量的一种功能. 在目前的大部分主流浏览器上, 都支持这种功能, 例如 Ineternet Explorer, FireFox, Netscape, Opera 等, 对应的 HTTP 版本应该是 HTTP 1.1.

要探测浏览器是否支持 HTTP 压缩, 只要查看浏览器请求的头中是否有如下字样:
Accept-Encoding: gzip, deflate
即可, 这个即是说明浏览器支持 gzip 和 deflate(一种压缩格式)的压缩内容. 这就意味着: 可以向浏览器返回默认的未压缩的文本, 也可以用 GZIP 和 deflate 压缩过后传送给它, 浏览器会自己探测这些内容并解压缩, 这就以为着传输某些资料的时候(例如文本的 HTML 代码)可以大大减少网络需要传送的内容数.

那么, 如何实现这个功能呢? 其实 Apache Tomcat 5 安装时候所自带的示例目录下都做好了一个过滤器用来实现这个功能了:
{Tomcat5.0安装目录}\webapps\jsp-examples\WEB-INF\classes\compressionFilters
下就是这个过滤器的源码和类文件, 使用时候只要将这些文件放入类路径中, 然后向 web.xml 中加入过滤器配置语句就可以了:

查看更多...

Tags: HTTP 压缩 filter 过滤

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 533
08-04
16

一个简单的数据压缩过滤器

这个小实例使用GZIP压缩的方式回传给浏览器,而IE5和NS6也都有支持Gzip的压缩格式。
这个方法在之前就有人提出过,因为是让网页在输出时经过压缩,可以让传输量变小很多,虽然现在的网络频宽对于用来看网页已经绰绰有余,但是档案大小太大的网页还是会造成一定的影响。

这里是压缩功能的代码:
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.zip.GZIPOutputStream;

查看更多...

Tags: 压缩 过滤 filter

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 487
08-04
16

Two Servlet Filters Every Web Application Should Have

《每一个WEB应用程序,都应该有两个过滤器》by Jayson Falkner
原文如下:
Almost every single web application you will ever make will seriously benefit from using servlet filters to both cache and compress content. A caching filter optimizes the time it takes to send back a response from your web server, and a compression filter optimizes the size of the content that you send from your web server to a user via the Internet. Since generating content and sending content over the World Wide Web are the bread and butter of web applications, it should be no surprise that simple components that aid in these processes are incredibly useful. This article details the process of building and using a caching filter and a compression filter that are suitable for use with just about any web application. After reading this article, you will understand caching and compressing, have code to do both, and be able to apply caching and compression to any of your future (or existing!) web applications.

Review: Servlet Filters in 10 Sentences
Servlet filters are powerful tools that are available to web application developers using the Servlet 2.3 specification or above. Filters are designed to be able to manipulate a request or response (or both) that is sent to a web application, yet provide this functionality in a method that won't affect servlets and JSPs being used by the web application unless that is the desired effect. A good way to think of servlet filters is as a chain of steps that a request and response must go through before reaching a servlet, JSP, or static resource such as an HTML page in a web application. Figure 1 shows the commonly used illustration of this concept.


查看更多...

Tags: filter zip

分类:Java&Jsp | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 573