我的java歷程

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

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

          在此我使用的環境是:
          tomcat5.5.17
          jstl1.2
          servlet2.5
          jsp2.1

          我以一個簡單的例子hello1來說明吧,發布工程時最重要的就是目錄結構了,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

          如果你按照以上目錄發布工程,拋出以下異常:
          (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 閱讀(3813) 評論(0)  編輯  收藏 所屬分類: Jsp&Servlet

          主站蜘蛛池模板: 金坛市| 城市| 蒲城县| 游戏| 北海市| 洞头县| 乐陵市| 蕉岭县| 电白县| 营山县| 永城市| 舟山市| 绵竹市| 乡宁县| 开远市| 黄浦区| 南岸区| 搜索| 德格县| 屯门区| 徐汇区| 宝兴县| 宽城| 肥乡县| 古交市| 新余市| 商水县| 雅江县| 北流市| 益阳市| 西和县| 儋州市| 隆昌县| 柯坪县| 观塘区| 苍梧县| 邵阳市| 泉州市| 沁源县| 柞水县| 当雄县|