JSP 2.0属于j2ee 1.4平台,它在JSP 1.2基础之上增加了新的功能。它保证了向下兼容,原先使用的JSP技术在JSP 2.0中都可以支持。JSP 2.0的新功能主要包括下面几部分:
1、web.xml格式变化
我们知道JSP 1.2可以在Java 2标准版1.3版本运行,而JSP 2.0要求使用Java 2标准版1.4或更新版本,JSP 2.0使用由Servlet 2.4规定的Web程序部署描述格式。
在Web程序描述文件web.xml中需要使用xml schema打头的格式。在web.xml中主要的变化是所有有关JSP的设置信息要放在<jsp-config>标记中。下面程序例1显示了一个web.xml大致的样子。
例1:
<?xml version="1.0" encoding="IS0-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">
.......
<jsp-config>
<taglib>
<taglib-uri>
http://www.icconcept.com/ics/sample-taglib
</taglib-uri>
<taglib-location>
/WEB-INF/jsp/sample-taglib.tld
</taglib-location>
</taglib>
........
<jsp-property-group>
<description>
For config the ICW sample application
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>/jsp/datareset.jsp</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>ISO-8859-1</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/prelude.jspf</include-prelude>
<include-coda>/jsp/coda.jspf</include-coda>
</jsp-property-group>
</jsp-config>
</web-app>