对于Web2.0来说,设计原则应该围绕其特点:平台性,个人为基础,交互性,轻量级编程。要实现个性化设计(豆瓣呢?)
在你每一个页面的顶端,你需要文档声明。是的,必须。
如果不指定文档类型,你的HTML不是合法的HTML,并且大部分浏览器会用“怪癖模式(quirks mode)”来处理页面,这意味着浏览器认为你自己也不知道究竟做什么,并且按浏览器自己的方式来处理你的代码。你可以是一个HTML大师,在地球上打遍 天下无敌手,或者你的HTML可以无瑕疵,CSS可以很完美,但如果没有文档声明,或者错误的文档声明,你的网页与一个短视的,独眼的长臂猿婴儿十分艰难 地堆砌起来的没两样。
XHTML 1.0 Strict(严格)的文档声明是这样的:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
下面的是XHTML 1.1的文档声明,作为XHTML的最新版本,看起来更完美,但还是有一些问题,随后我们会稍微讲解……
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd“>
如果你不愿放弃HTML 4或者你还有Netscape 4死忠用户,你可以使用XHTML 1.0 Transitional(过渡型):
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
你使用这的唯一理由是你还要兼容老版本的,少用的浏览器。过渡型XHTML 1.0允许HTML 4的表现元素,其也可能在如Netscape 4的浏览器中表现更好。但使用这些元素将对你网页的效率和可用性有害。
最后,如果你是使用框架的怪人之一,可以使用像下面一样的XHTML 1.0 Frameset(框架)文档类型声明:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd“>
注意DOCTYPE标签必须大写和前置一个英文半角感叹号!。它是唯一一个打破规则的标签,它不需要关闭。
语言声明
即使HTTP头或者在html起始标签内设置了xml:lang属性,你也必须为文档指定一个主要语言。尽管处理一个合法的XHTML文档这不 是必须的,但也是一个易用性的考虑。值是缩写的,比如en(English,英语),fr(French,法语),de(German,德语)或者mg (Malagasy,这是什么语?译者也不知道,呵呵。——译者注)。
声明一个主要用英语内容的文档,例子是这样的:
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en”>
在声明主要语言之后,假如还需要使用其他语言,你还可以在内联中使用xml:lang属性(比如<span xml:lang=”de”>HTML Hund</span>)。
内容类型
HTML文档的媒体类型和字体集也许要指定,可以使用HTTP头来完成,比如:
Content-Type: text/html; charset=UTF-8
HTTP头部的第一部分(如text/html)是文件MIME类型,让浏览器知道文件的媒体类型因此可以知道怎么处理。所有的文件都有MIME类型。JPEG图像是image/jpeg,CSS文件是text/csss和HTML一般使用text/html。
HTTP头部的第二部分(如UTF-8部分)是字符集。
也许设置HTTP头的最简易方法是在HTML中使用“HTTP同义(HTTP-equivalent)”的头标签,像这样:
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
些微复杂当更好的方法是使用服务器端脚本语言来发送头。用PHP的话,你可以这样做:
<? header(”Content-Type: text/html; charset= UTF-8″); ?>
如果你不愿意(或不能)使用服务器端脚本语言,你也许可以直接给服务器设置一个“.htaccess”文件。大部分服务器(Apache兼容) 可以在根目录使用一个“.htaccess”的小文本文件,写入下面的内容,你就可以把所有的“html”后缀文件都与MIME类型和字符集关联:
AddType text/html;charset=UTF-8 html
字符集包括大部分西方基于拉丁文语言的“ISO-8859-1”,日语的“SHIFT_JIS”,中文的“GB18030”和UTF-8,一个 Unicode Transformation Format版本,提供大范围的多种语言的单个字符。基本上,你应该使用一个你知道的,能为你用户清楚认知的字符集。除非你使用基于拉丁语的语言(包括英 语)(ISO-8859-1被普遍接受的),你应该使用UTF-8因为它可以显示大多数语言的大多数字符,使用它也是安全的,因为它可以在大部的计算机上 使用。
注意
XHTML应该当作application/xhtml+xml的MIME类型来使用,再清楚不过,这是XML程序。不幸的是,大部分浏览器没 有对这没有第一线索。所以,一般认为使用text/html的MIME类型是不错的。根据W3C的建议和网页标准工程的未来亮点,调味的XHTML 1.0也许可以作text/html使用,但XHTML 1.1不应该,这就是这个网站以XHTML 1.0 Strict(严格)作为例子,假定text/html的MIME类型。但是你仍然可以(或许不应该)为它们设置正确的MIME类型给浏览器,轻微的调用 一下服务器端即可。
这个网站使用PHP为XHTML 1.1设置application/xhtml+xml的MIME类型给那些能够理解和处理这个类型的浏览器(如Mozilla),为XHTML 1.0 Strict设置text/html给其他浏览器(如IE)。为每一个页面的顶部加入如下代码:
<? if(stristr($_SERVER["HTTP_ACCEPT"],”application/xhtml+xml”)){ header(”Content-Type: application/xhtml+xml; charset=UTF-8″); echo(’<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>’); } else { header(”Content-Type: text/html; charset=UTF-8″); echo (’<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>’); } ?>
这些检查核实浏览器是否接受application/xhtml+xml的MIME类型,如果接受,就发送这个MIME类型并把XHTML 1.1文类类型写到HTML中。如果这个MIME类型不被接受,就发送text/html的MIME类型并把XHTML 1.0 Strict(严格)的文档类型写入HTML。
除了你知道你正在做着正确的事情和为自己准备将来的路的平和想法外,最直接的益处就是,使用这个方法,Mozilla浏览器把你的文件当作 XML程序对待并且如果你的XHTML还没有抓痒,就是说不合式的,Mozilla就不会工作。然后你就可以排错了,而不需要用校验器来运行你的文档了。
I studied CSS+DIV these days. It is cool~~ Different with the traditional table div+CSS is more controllable and reusable. I studied how to make a round corner with it and the Inheritance between this tags. It makes the web page design better. In the following days, I will add more features to my side bar as follows:
- make the sidebar scalable
- use the exiting code to make the page changed by user’s option
- make the feature “search by methods and fields” come true
In this projects remember user’s status is critical.
GlassFish has a concept of a domain. More precisely, it is the administrative domain. At first, it may be perceived a little difficult to understand, especially given that in Java EE paradigm, one is used to servers rather than domains. This is especially true with developers.
This post tries to explain what a GlassFish Domain (domain, henceforth) is, how to use it effectively if you want to quickly deploy your applications to GlassFish and the reasons to call it a domain.
A domain (statically) is an administrative name space. It’s a boundary, all GlassFish entities within which are controlled by an administrator or more precisely administrative three tuple (Let’s call it Admin 3T). This three tuple is called “admin user, admin password, certificate database password (or master password). If you are a developer, you don’t really care about the master password and it defaults to “changeit“. This is the password with which your keystore (cacerts.jks) is locked and most of the times, you don’t care about this.
This is how your domains look like.
A domain (dynamically) is a Java EE Engine. Thus it is your server, once you have started it. In other words, at run time, a domain = server. Thus, a running domain can host user Java EE applications and can be effectively used as the target for your deployments. For developers, this is what they care about. It is for developers that this gap has been bridged and they can forget about the domain. The defaults are so carefully chosen that you’d never need to know about the fact that you are managing and deploying to a domain!
So, what is that that domain provides on top of behaving like a server? Here is a list of things:
- Domain provides you with a built-in administration capability.
- Domain has multiple system applications predeployed which facilitate the management. Thus the entire admin console
-
is available as a system web application. All you need to do it connect to “http://localhost:admin-port(4848)”. - Domain has another system application predeployed to take care of all the asadmin commands. Note that (almost) all the asadmin commands invoke the running domain in
- Domain has an EJB Timer Service already configured to work with. A timer database is also created.
- Domain has a JDBC Connection Pool configured for the EJB timer database.
- Domain has two keyfiles created by default so that one has authentication realms for the security conscious people. All you need to do is create the security mappings in your applications.
- Domain has a default web.xml that decides the default behavior of all deployed web applications.
- Domain has a JMX Connector’s Server end so that you can easily connect to the admin infrastructure, using JConsole and browse the MBeans. As you know MBeans are to Administration what EJB’s are to Enterprise Computing.
All this is enabled by a simple set of steps:
- Either you download GlassFish and invoke ant -f setup.xml that creates the so-called fully configured, ready-to-go default domain, OR
- Explode the GlassFish image and do [glassfish]/bin/asadmin create-domain –adminport 4848 mydomain
All this is great. But how does a developer exploit it?
Simple. Your answer is NetBeans. Just download “The” IDE and do the following:
- Go to the Runtime tab and right click for “Adding a target server”.
See how NetBeans itentifies your default domain, domain1. The port is also identified. This is the administration port. Next, you could provide the user name and password for administration. That’s it. This domain is now deployment ready . - You need to create a web application. Just create it using the intuitive menus in the IDE.
- The IDE is so well integrated with the GlassFish domain/server is that it just allows you to start the GlassFish server in debug mode and debug your application. This is really seamless!
-
- Here is your application deployed and being tested!
This is how I develop and test my applications. I am a developer. Hope fellow developers find this as easy as I do.
If you are a CLI fan, there are a bunch of intuitive asadmin commands that configure the domain/server.
If you are an ANT fan, there are ANT tasks like sun-appserv-deploy that help you continue to write your build.xml files.
We are planning to integrate asadmin into a scripting language of your choice. You’d have to wait till Mustang releases, though.
I know this sounds easy. But it sounds so because it is so.
Finally, the $1M Question: Why do you call it a domain? Well, the reason lies in more sophisticated Sun Software like Application Server Standard Edition (SE) . When you enter into the real enterprise arena, it is no more a server. It is a bunch of servers (which are also known as app server instances, each of which is a Java EE Engine) that are woven into clusters to impart the coveted high availability. Still, the “Administrative” domain remains the same. You don’t have to learn a new concept when you go from one edition of the product to an advanced one. A set of simple rules emerges:
- A Domain is comprised of a set of Instances. A Domain is “bigger” than an Instance.
- Domain has a “dual nature”. For a simple case, Domain equals Instance (I tend to relate to the dual nature of electron — “is it a wave, is it a particle” here
).
Thus, it is the best of both the worlds: For developers, a domain is a server. For system administrators, a domain is something that they manage so that an uninterrupted service is provided!
Makes sense to me. How about you? Please let me know …
