我的java歷程

          tomcat5.5.17+jstl1.2+servlet2.5+jsp2.1配置

          tomcat5.5.17+jstl1.2+servlet2.5+jsp2.1配置

          在此我使用的環(huán)境是:
          tomcat5.5.17
          jstl1.2
          servlet2.5
          jsp2.1

          我以一個簡單的例子hello1來說明吧,發(fā)布工程時最重要的就是目錄結構了,hello1是根目錄,放在tomcat中的webapps里,先看看目錄結構:
          hello1\index.jsp
          hello1\response.jsp
          hello1\WEB-INF\lib\javaee.jar
          hello1\WEB-INF\lib\jsf-api.jar
          hello1\WEB-INF\lib\jsf-impl.jar
          hello1\WEB-INF\lib\jstl-1.2.jar
          hello1\WEB-INF\web.xml

          如果你按照以上目錄發(fā)布工程,拋出以下異常:
          (1)  java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
          (2)  或打開頁面后顯示:

          HTTP Status 404 - /hello1/


          type Status report

          message /hello1/

          description The requested resource (/hello1/) is not available.


          Apache Tomcat/5.5.17


          則將javaee.jar包再copy一份放在tomcat目錄的common\lib下就不會了。
          關于用到的javaee.jar、jsf-api.jar、jsf-impl.jar、jstl-1.2.jar這四個包可以通過myeclipse中獲得,如果你安裝了myeclipse5.5的話,我安裝的是MyEclipse 5.5.1 GA,這四個包的所在的目錄是:MyEclipse 5.5.1 GA\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_5.5.1\data\libraryset\EE_5\

          到此,再給出具體的文件代碼吧。
          (1)  hello1\index.jsp

          <%@ taglib uri="<%@ taglib uri="

          <html>
          <head><title>Hello</title></head>
          <body bgcolor="white">
          <h2>Hello, my name is Duke. What's yours?</h2>
          <form method="get">
          <input type="text" name="username" size="25">
          <p></p>
          <input type="submit" value="Submit">
          <input type="reset" value="Reset">
          </form>

          <c:if test="${fn:length(param.username) > 0}" >
            <
          %@include file="response.jsp" %>
          </c:if>
          </body>
          </html>

          (2)  hello1\response.jsp

          <h2><font color="black">Hello, ${param.username}!</font></h2>

          (3)  hello1\WEB-INF\web.xml

          <?xml version="1.0" encoding="ISO-8859-1"?>

          <web-app xmlns="         xmlns:xsi="         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd"
                   version="2.5">

          <jsp-config> 
           <jsp-property-group>
            <display-name>hello1</display-name>
            <url-pattern>*.jsp</url-pattern>
            <el-ignored>false</el-ignored>
            <scripting-invalid>false</scripting-invalid>
            <is-xml>false</is-xml>
            <!-- <include-prelude>/template/prelude.jspf</include-prelude> -->
            <!-- <include-coda>/template/coda.jspf</include-coda> -->
           </jsp-property-group>
          </jsp-config>
          </web-app>


          成功之后頁面顯示為:

          Hello, my name is Duke. What's yours?

           

          Hello, afdfadsfads!

          posted on 2007-07-06 13:35 landril 閱讀(3824) 評論(0)  編輯  收藏 所屬分類: Jsp&Servlet

          主站蜘蛛池模板: 财经| 阳东县| 瑞丽市| 三穗县| 什邡市| 怀柔区| 虞城县| 北碚区| 木里| 壶关县| 高密市| 巩义市| 明光市| 桂阳县| 湖州市| 界首市| 桃园县| 洱源县| 遵义县| 宁波市| 邵东县| 深泽县| 浦北县| 宁河县| 渝北区| 木兰县| 定安县| 苗栗市| 婺源县| 开江县| 兴城市| 常宁市| 丘北县| 穆棱市| 九江县| 南雄市| 梅州市| 若尔盖县| 镇雄县| 铜梁县| 广安市|