91精品国产综合久久香蕉的特点,久久午夜影视,国产三线在线http://www.aygfsteel.com/dazern/category/7953.html 天之道,利而不害;圣人之道,為而不爭;信言不美,美言不信;善者不辯,辯者不善;知者不博,博者不知! zh-cnTue, 27 Feb 2007 12:17:56 GMTTue, 27 Feb 2007 12:17:56 GMT60用eclipse + wtp 開發JSP(轉) http://www.aygfsteel.com/dazern/articles/34434.html夏天的零度夏天的零度Thu, 09 Mar 2006 03:06:00 GMThttp://www.aygfsteel.com/dazern/articles/34434.htmlhttp://www.aygfsteel.com/dazern/comments/34434.htmlhttp://www.aygfsteel.com/dazern/articles/34434.html#Feedback0http://www.aygfsteel.com/dazern/comments/commentRss/34434.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/34434.html作者:explorers
源:
http://blog.csdn.net/explorers/archive/2005/08/15/454769.aspx
      http://www.eclipseworld.org/bbs/read.php?tid=680&fpage=1&toread=&page=1

現在eclipse越來越好用了,隨著sun jdk5.0的補丁4的推出,eclipse3.1也正式發布,
二者結合,速度比以前快了很多。而wtp0.7 m5版本放出也有了一段時間,這個月月
底可能wtp0.7會有release了。現在二者都基本成熟,用eclipse+wtp開發JSP是很方便
的,但是關于wtp插件的配置和使用方面的文章卻不多。很多人覺得wtp太麻煩,
配不好不能用,本人一直用wtp開發jsp,常有朋友問相關的問題,所以寫了這篇文章
用來介紹WTP的配置和開發JSP的步驟。
  這里介紹的主要是jdk5.0b4 + eclipse3.1 + wtp0.7m5環境下的配置和開發,
其他版本有細微的差異,但是主要的過程是相同的。
 
  1. 下載安裝
        這是當然的第一步啦,這里是連接:
       
http://www.eclipse.org/webtools/index.html
    2. 配置
有很多項需要配置,羅列如下:
1) 配置java-buildpath

2) 配置JDK
TOMCAT運行的時候需要JDK,eclipse自動找到的是jre,如下圖:

3) 配置xml 和 internet 緩存
在web應用中通常有很多的xml文件,默認情況下wtp會去驗證這些xml文件,
這就需要有這些xml文件的定義dtd或者xsd文件。
wtp默認的會自動去下載,下載下來之后可以緩存之后供以后使用。
所以首先我們要打開緩存功能。見下圖,把disable cashing的勾去掉即可。

也可以把常用的xml文件的定義文件配置在xmlcatalog里邊,
這樣進行xml驗證的時候會自動使用這些文件,見下圖:

實在不行,只有把xml自動驗證去掉了,見Validation選項。
4) 配置tomcat服務器
現在我們來配置tomcat,其他服務器的配置大致相同,如下圖所示:

輸入tomcat的路徑和JDK

3 開發一個JSP
首先new一個dynamic web project,在確定之后會提示是否進入j2ee
perspective,選擇否,進入java perspective,如下圖:
(說明:如果是以前的版本,在new的時候可能找不到dynamic web
project,而是有一個Flexible project,那就先建一個Flexible project,
然后在這個project下建立就可以找到dynamic web project了!)
注意:第一次運行的時候,由于wtp需要驗證web.xml這個文件,所以
會去下載web.xml驗證要用到的dtd或者xsd,所以速度比較慢,
耐心等待,等所需要的文件全部下載下來之后以后就ok了。

工程建好之后,在下面創建java class和一個jsp文件,如下圖,
注意目錄結構:

上面圖中的java類和jsp都創建好了,現在我們在tomcat中測試這個jsp
頁面,右擊 webtests這個項目,在菜單中有一項run on server,點擊
后出來選擇服務器的對話框,選擇我們建立的tomcat服務器,然后添加
項目,finish。wtp會在eclipse內打開一個瀏覽器打開這個項目。
  注意到wtp自動新建并打開的工程servers,這個工程是在tomcat下
測試jsp頁面所必須要有的,而且必須是打開的狀態,否則無法進行jsp
測試。

4. 常見問題的解決

1) no server錯誤
  這個錯誤在一些版本的wtp里邊,就是一個紅叉叉的對話框,說no
server,此時請確認打開了servers這個工程。

2) 類未定義錯誤
  如果你在web project中使用了一些外部的jar,比如說log4j之類,你
可能在工程的classpath中已經添加了這個jar,但是運行時還會找不到類,
這是因為這個jar沒有被copy到工程的部署目錄的 WEB-INF/lib目錄下,
顯示 Navigator視圖, 如下圖。".deployables" 是一個web project
被部署到的地方。把用到的jar 拷貝到lib下即可。
(另一個解決辦法是把jar拷貝到 /webtests/WebContent/WEB-INF/lib
目錄下,但是這樣做有一個缺點,在你想要查看你用到的包中類的源碼
會比較麻煩。我的做法是把常用的包配置到user library中,設定好源碼,
再加入到工程的classpath中。如果把jar拷到
/webtests/WebContent/WEB-INF/lib目錄下,那么這個時候webtests
這個工程的classpath中就有兩份同樣的包,在查看源碼的時候都要選擇,
而且會以 /WEB-INF/lib下的包為優先,這可能跟classpath中的順序有關,
但是不方便。所以直接把jar拷到 .deployables目錄下,可以解決這個
問題。希望以后版本的wtp中能解決這樣的問題,如果能夠自動的把
classpath中設置的所有jar都拷到 .deployables目錄下就方便了。)

3) context錯誤
  有的時候會出現context錯誤,大致有兩種,一種是context重復錯誤,
這種情況下,tomcat無法啟動。
  在servers工程里,把server.xml中重復的context條目手工刪除即可。

另一種錯誤是" no context"錯誤,這個時候tomcat可以啟動,但是瀏
覽器里邊會說找不到頁面,這就是說server.xml中沒有這個context,解決
的辦法是在servers explorer視圖中把server 刪除,然后重新添加這個web
應用,有時這樣還不能解決可以重新配置server。



夏天的零度 2006-03-09 11:06 發表評論
]]>
tomcat 5.5 的The Apache Tomcat Native library which allows optimal performance 的解決 http://www.aygfsteel.com/dazern/articles/33862.html夏天的零度夏天的零度Mon, 06 Mar 2006 07:38:00 GMThttp://www.aygfsteel.com/dazern/articles/33862.htmlhttp://www.aygfsteel.com/dazern/comments/33862.htmlhttp://www.aygfsteel.com/dazern/articles/33862.html#Feedback2http://www.aygfsteel.com/dazern/comments/commentRss/33862.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/33862.htmlTomcat啟動的時候出現下面這樣的提示:

2006-1-26 19:44:11 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Java\jdk1.5.0_05\bin;.;C:\WINDOWS\system32;C:\WINDOWS;d:\ruby\bin;.;..;D:\Java\jrockit-R26.0.0-jdk

實際這是建議使用apache的apr。

如果想使用apr的話, 實際操作很簡單,

下載 http://tomcat.heanet.ie/native/1.1.1/binaries/win32/tcnative-1.dll

將這個文件復制到C:\WINDOWS\system32\下面

然后重新啟動tomcat,就會發現tomcat 的控制臺信息為:
2006-1-26 19:48:42 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-9080

詳情見 http://tomcat.apache.org/tomcat-5.5-doc/apr.html

http://www.google.com/search?hl=zh-CN&newwindow=1&q=The+Apache+Tomcat+Native+library+which+allows+optimal+performance&btnG=%E6%90%9C%E7%B4%A2&lr=




夏天的零度 2006-03-06 15:38 發表評論
]]>
Tomcat5.5配置經典教程——Configuring & Using Apache Tomcat http://www.aygfsteel.com/dazern/articles/32826.html夏天的零度夏天的零度Tue, 28 Feb 2006 04:31:00 GMThttp://www.aygfsteel.com/dazern/articles/32826.htmlhttp://www.aygfsteel.com/dazern/comments/32826.htmlhttp://www.aygfsteel.com/dazern/articles/32826.html#Feedback0http://www.aygfsteel.com/dazern/comments/commentRss/32826.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/32826.html                                                 Configuring & Using Apache Tomcat
原文地址:http://www.coreservlets.com/Apache-Tomcat-Tutorial/

                                                               Introduction

CSAJSP
Core Servlets & JSP 2/E
MSAJSP
More Servlets & JSP
Following is a guide to installing and configuring Apache Tomcat 5.5 for use as a standalone Web server (for development) that supports servlets 2.4 and JSP 2.0. (Note: Apache Tomcat is sometimes referred to as "Jakarta Tomcat" since the Apache Java effort is known as "The Jakarta Project"). This Tomcat tutorial covers version 5.5.9; for coverage of older Tomcat versions (Apache Tomcat 5.0.x and Apache Tomcat 4.0.x), please see the Apache Tomcat 5.0 and 4.0 tutorial.

Using Tomcat as a deployment server or integrating Tomcat as a plugin within the regular Apache server or a commercial Web server is more complicated than what is described in this tutorial. Although such integration is valuable for a deployment scenario (see http://jakarta.apache.org/tomcat/tomcat-5.5-doc/), my goal here is to show how to use Tomcat as a development server on your desktop. Regardless of what deployment server you use, you'll want a standalone server on your desktop to use for development.

The examples here assume you are using Windows, but they can be easily adapted for Linux, Solaris, and other versions of Unix. I've gotten many reports of successful use on MacOS X, but don't know the setup details. Except when I refer to specific Windows paths (e.g., C:\blah\blah), I use URL-style forward slashes for path separators (e.g., install_dir/webapps/ROOT). Adapt as necessary.

The information here is adapted from the introductory setup and configuration chapter of Core Servlets and JavaServer Pages, 2nd Edition, Volume 1 from Sun Microsystems Press and Prentice Hall. For the book table of contents, index, source code, etc., please see http://volume1.coreservlets.com/. For information on training courses (either at public venues or on-site at your company) taught by the author of the book and this Apache Tomcat tutorial, please see this servlet, JSP, Struts, JSF, and Java training courses page. To report errors or omissions in this writeup or to inquire about on-site training courses on servlets, JSP, Struts, JSF, and Java, please contact Marty Hall at hall@coreservlets.com.

Executive Summary

JSP, Servlet, Struts, & JSF Training
Looking for hands-on training? Tired of inexperienced instructors teaching someone else's course materials? Want a choice of public or in-house courses? Check out these servlet, JSP, Struts, and JSF training courses.
Distinctive features:
? Personally developed and taught by Marty Hall, an experienced developer, award-winning instructor, 4-time JavaOne speaker, and author of Core Servlets and JSP, More Servlets and JSP, and this Apache Tomcat tutorial.
? A choice of on-site training courses at your organization or training courses at public venues.
? Well-tested, having been used by Marty for courses for more than 100 different organizations in the USA, Canada, Australia, Japan, Puerto Rico, and the Philippines.
I give extremely detailed instructions in the following sections. If you're pretty experienced and just want a short summary, this section will probably be enough for you. You can also download a preconfigured Apache Tomcat version that incorporates all of the modifications of this tutorial and includes a sample development directory, shortcuts, and autoexec.bat file.

  1. Install the JDK. Make sure JDK 1.4 or 1.5 is installed and your PATH is set so that both "java -version" and "javac -help" give a result.
  2. Configure Tomcat.
    1. Download the software. Go to http://jakarta.apache.org/site/binindex.cgi#tomcat and download and unpack the zip file for the current release build of Tomcat 5.5. If you use Tomcat 5.5 with JDK 1.4 (recommended), you have to also download and unpack the "Compat" zip file. Also see the preconfigured Apache Tomcat version.
    2. Set the JAVA_HOME variable. Set it to refer to the base JDK directory, not the bin subdirectory.
    3. Change the port to 80. Edit install_dir/conf/server.xml and change the port attribute of the Connector element from 8080 to 80.
    4. Turn on servlet reloading. Edit install_dir/conf/context.xml and change <Context> to <Context reloadable="true">.
    5. Enable the invoker servlet. Go to install_dir/conf/web.xml and uncomment the servlet and servlet-mapping elements that map the invoker servlet to /servlet/*.
    6. Change the DOS memory settings. If you are on Windows 98/Me and get an "Out of Environment Space" error message when you start the server, right-click on install_dir/bin/startup.bat, select Properties, select Memory, and change the Initial Environment entry from Auto to at least 2816. Repeat the process for install_dir/bin/shutdown.bat. Not necessary on recent version of Windows.
    7. Set the CATALINA_HOME variable. Optionally, set CATALINA_HOME to refer to the top-level Tomcat installation directory. Not necessary unless you copy the startup scripts instead of making shortcuts to them.
    8. Use a preconfigured Tomcat version. Optionally, use a version of Jakarta Tomcat that has all of the above changes already made, and has the test HTML, JSP, and servlet files already bundled.
  3. Test the server.
    1. Verify that you can start the server. Double-click install_dir/bin/startup.bat and try accessing http://localhost/.
    2. Check that you can access your own HTML & JSP pages. Drop some simple HTML and JSP pages into install_dir/webapps/ROOT and access them with http://localhost/filename.
  4. Set up your development environment.
    1. Create a development directory. Put it anywhere except within the Tomcat installation hierarchy.
    2. Make shortcuts to the Tomcat startup & shutdown Scripts. Put shortcuts to install_dir/bin/startup.bat and install_dir/bin/shutdown.bat in your development directory and/or on your desktop.
    3. Set your CLASSPATH. Include the current directory ("."), the servlet/JSP JAR files (install_dir/common/lib/servlet-api.jar and install_dir/common/lib/jsp-api.jar), and your main development directory from Step 1.
    4. Bookmark the servlet & JSP javadocs. Add install_dir/webapps/tomcat-docs/servletapi/index.html and install_dir/webapps/tomcat-docs/jspapi/index.html to your bookmarks/favorites list.
  5. Compile and test some simple servlets.
    1. Test a packageless servlet. Compile a simple servlet, put the .class file in install_dir/webapps/ROOT/WEB-INF/classes, and access it with http://localhost/servlet/ServletName.
    2. Test a servlet that uses packages. Compile the servlet, put the .class file in install_dir/webapps/ROOT/WEB-INF/classes/packageName, and access it with http://localhost/servlet/packageName.ServletName.
    3. Test a servlet that uses packages and utility classes. Compile a servlet, put both the servlet .class file and the utility file .class file in install_dir/webapps/ROOT/WEB-INF/classes/packageName, and access the servlet with http://localhost/servlet/packageName.ServletName. This third step verifies that the CLASSPATH includes the top level of your development directory.
  6. Establish a simplified deployment method.
    1. Copy to a shortcut. Make a shortcut to install_dir/webapps/ROOT. Copy packageless .class files directly there. With packages, copy the entire directory there.
    2. Use the -d option of javac. Use -d to tell Java where the deployment directory is.
    3. Let your IDE take care of deployment. Tell your IDE where the deployment directory is and let it copy the necessary files.
    4. Use ant or a similar tool. Use the Apache make-like tool to automate copying of files.
  7. Get more info. Access the complete set of Tomcat docs, get free JSP and servlet tutorials, read the official servlet and JSP specifications, get JSP-savvy editors and IDEs, look for J2EE jobs, etc.

Install the JDK

Your first step is to download and install Java. The servlet 2.4 (JSP 2.0) specification requires JDK 1.3 or later; J2EE 1.4 (which includes servlets 2.4 and JSP 2.0) requires JDK 1.4 or later. You might as well get a recent Java version, so use JDK 1.4 or 1.5. If you know which of those Java versions will be used on your project, get that one. If not, I recommend JDK 1.4 instead of JDK 1.5 so that you don't limit portability by accidentally using Java 1.5 features in your code. See the following sites for download and installation information.

  • JDK 1.4 for Windows, Linux, and Solaris: http://java.sun.com/j2se/1.4/download.html. Be sure you download the full SDK (Software Development Kit), not just the JRE (Java Runtime Environment). The JRE is only for running already-compiled .class files, and lacks a compiler.
  • JDK 1.5 for Windows, Linux, and Solaris: http://java.sun.com/j2se/1.5.0/download.jsp. Be sure you download the full JDK (J2SE Development Kit), not just the JRE (Java Runtime Environment). The JRE is only for running already-compiled .class files, and lacks a compiler.
  • JDK 1.4 for MacOS: http://developer.apple.com/java/.

Once you've installed Java, confirm that everything including your PATH is configured properly by opening a DOS window and typing "java -version" and "javac -help". You should see a real result both times, not an error message about an unknown command. Or, if you use an IDE, compile and run a simple program to confirm that the IDE knows where you installed Java.

Configure Tomcat

JSP, Servlet, Struts, & JSF Training
Looking for hands-on training? Tired of inexperienced instructors teaching someone else's course materials? Want a choice of public or in-house courses? Check out these servlet, JSP, Struts, and JSF training courses.
Distinctive features:
? Personally developed and taught by Marty Hall, an experienced developer, award-winning instructor, 4-time JavaOne speaker, and author of Core Servlets and JSP, More Servlets and JSP, and this Apache Tomcat tutorial.
? A choice of on-site training courses at your organization or training courses at public venues.
? Well-tested, having been used by Marty for courses for more than 100 different organizations in the USA, Canada, Australia, Japan, Puerto Rico, and the Philippines.
Configuring Tomcat involves five main steps and four optional steps:

  1. Downloading the Jakarta Tomcat software.
  2. Setting the JAVA_HOME variable.
  3. Changing the port from 8080 to 80.
  4. Telling Tomcat to reload servlets when they are modified.
  5. Enabling the invoker servlet
  6. Changing the DOS memory settings. (Win98/Me only)
  7. Setting the CATALINA_HOME variable. (Optional; rarely used)
  8. Using a preconfigured version of Tomcat with these changes already made. (Optional; widely used)
  9. Using the Windows .exe installer instead of the .zip file (Not Recommended)

Details of each step are given below. If Tomcat is already running, restart it after performing these steps.

1. Download the Apache Tomcat Software

Go to http://jakarta.apache.org/site/binindex.cgi#tomcat and download the zip file for the current release build of Jakarta Tomcat 5.5. If you need to use an older version of Tomcat to be compatible with an app server such as BEA WebLogic 8.1 that does not support JSP 2.0, please see the older Apache Tomcat 5.0 and 4.0 tutorial.

Note that if you use Tomcat 5.5 with JDK 1.4 (the recommended setup for most users), you have to download both the main zip file and the "Compat" zip file. If you use Tomcat 5.5 with JDK 1.5, you do not need the "Compat" zip file, but it is better to use JDK 1.4 (unless you will deploy on JDK 1.5 only) so that you do not limit portability by accidentally using JDK 1.5 constructs in your Java code.

Save the zip file(s) on your PC and unzip into a location of your choice. You specify the top-level directory (e.g., C:\) and the zip file has embedded subdirectories (e.g., jakarta-tomcat-5.5.9). Thus, C:\jakarta-tomcat-5.5.9 is a common resultant installation directory. Note: from this point forward, I'll refer to that location as install_dir. For Windows, there is also a .exe installer; I prefer the .zip file, but see the .exe installer section for notes on the differences between the two.

Alternatively, you can use my preconfigured Jakarta Tomcat version. This version already has the port changed to 80, servlet reloading enabled, the invoker servlet turned on, and the "Compat" package included. It also comes with a sample development directory and autoexec.bat file.

2. Set the JAVA_HOME Variable

Next, you must set the JAVA_HOME environment variable to tell Tomcat where to find Java. Failing to properly set this variable prevents Tomcat from compiling JSP pages. This variable should list the base JDK installation directory, not the bin subdirectory. For example, on almost any version of Windows, if you installed the JDK in C:\j2sdk1.4.2_08, you might put the following line in your C:\autoexec.bat file.

  set JAVA_HOME=C:\j2sdk1.4.2_08

On Windows XP, you could also go to the Start menu, select Control Panel, choose System, click on the Advanced tab, press the Environment Variables button at the bottom, and enter the JAVA_HOME variable and value directly. On Windows 2000 and NT, you do Start, Settings, Control Panel, System, then Environment. However, you can use C:\autoexec.bat on those versions of Windows also (unless a system administrator has set your PC to ignore it).

3. Change the Port to 80

Assuming you have no other server already running on port 80, you'll find it convenient to configure Tomcat to run on the default HTTP port (80) instead of the out-of-the-box port of 8080. Making this change lets you use URLs of the form http://localhost/blah instead of http://localhost:8080/blah. Note that you need admin privileges to make this change on Unix/Linux. Also note that some versions of Windows XP automatically start IIS on port 80. So, if you use XP and want to use port 80 for Tomcat, you may need to disable IIS (see the Administrative Tools section of the Control Panel).

To change the port, edit install_dir/conf/server.xml and change the port attribute of the Connector element from 8080 to 80, yielding a result similar to that below.

    <Connector port="80" ...
      maxThreads="150" minSpareThreads="25" ...

You can also:

4. Turn on Servlet Reloading

The next step is to tell Tomcat to check the modification dates of the class files of requested servlets, and reload ones that have changed since they were loaded into the server's memory. This slightly degrades performance in deployment situations, so is turned off by default. However, if you fail to turn it on for your development server, you'll have to restart the server every time you recompile a servlet that has already been loaded into the server's memory. Since this tutorial discusses the use of Tomcat for development, this change is strongly recommended.

To turn on servlet reloading, edit Edit install_dir/conf/context.xml and change

  <Context>

to

  <Context reloadable="true">

You can also:

5. Enable the Invoker Servlet

The invoker servlet lets you run servlets without first making changes to your Web application's deployment descriptor (i.e., the WEB-INF/web.xml file). Instead, you just drop your servlet into WEB-INF/classes and use the URL http://host/servlet/ServletName (or http://host/webAppName/servlet/ServletName once you start using your own Web applications; see Section 2.11 of the book for details on Web apps). The invoker servlet is extremely convenient when you are learning and even when you are doing your initial development. You almost certainly want to enable it when learning, but you should disable it again before deploying any real applications.

To enable the invoker servlet, uncomment the following servlet and servlet-mapping elements in install_dir/conf/web.xml. Do not confuse this Apache Tomcat-specific web.xml file with the standard one that goes in the WEB-INF directory of each Web application.

    <servlet>
        <servlet-name>invoker</servlet-name>
        <servlet-class>
          org.apache.catalina.servlets.InvokerServlet
        </servlet-class>
        ...
    </servlet>
    ...
    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>

You can also:

6. Change DOS Memory Settings (Win 98/Me Only)

If you use Windows 98/Me, you may also have to change the DOS memory settings for the startup and shutdown scripts. If you get an "Out of Environment Space" error message when you start the server, you will need to right-click on install_dir/bin/startup.bat, select Properties, select Memory, and change the Initial Environment entry from Auto to at least 2816. Repeat the process for install_dir/bin/shutdown.bat. This step is not necessary in more recent versions of Windows.

7. Set the CATALINA_HOME Variable (Optional)

If you are going to make copies of the Tomcat startup or shutdown scripts (e.g., startup.bat and shutdown.bat), it is also helpful to set the CATALINA_HOME environment variable to refer to the top-level directory of the Apache Tomcat installation (e.g., C:\jakarta-tomcat-5.5.9<%2

夏天的零度 2006-02-28 12:31 發表評論
]]>
Tomcat 5.5.15相關配置 http://www.aygfsteel.com/dazern/articles/32776.html夏天的零度夏天的零度Tue, 28 Feb 2006 00:51:00 GMThttp://www.aygfsteel.com/dazern/articles/32776.htmlhttp://www.aygfsteel.com/dazern/comments/32776.htmlhttp://www.aygfsteel.com/dazern/articles/32776.html#Feedback0http://www.aygfsteel.com/dazern/comments/commentRss/32776.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/32776.html 作者: hasek   發表日期: 2006-02-21 00:08   復制鏈接

     Tomcat作為一個很優秀的web application server的確值得大家使用,特別是熟悉java的愛好者,不過它的配置并不象它的應用那么優秀,至少在配置上有很多瑣碎的事情要做,現在我將我自己配置最新的tomcat5.5.15的一點心得告訴大家:

總共涉及三個方面,也是tomcat配置比較煩瑣的地方

一.與apache的配置(暫略,晚點再將配置詳細介紹)

二.使tomcat5.5.15支持jstl標簽
    這個是最簡單的配置,只要按照以下方法,就可以配置成功.
    1.下載 jakarta-taglibs-standard-1.1.2.zip (windows)
              jakarta-taglibs-standard-1.1.2.tar.gz(linux)
    2.解壓在解壓的lib目錄下找到jstl.jar,standard.jar這兩個.jar文件,將他們復制到 你的站點/WEB-INF/lib文件夾下,在tld目錄下將所有的.tld文件復制到 你的站點/WEB-INF/taglib/文件下
    3.配置 你的站點/WEB-INF/web.xml文件,在</webapp>前添加如下內容
  <taglib>
  <taglib-uri>http://www.hnlinux.net/core</taglib-uri>
  <taglib-location>/WEB-INF/taglibs/c.tld</taglib-location>
  </taglib>

  <taglib>
  <taglib-uri>http://www.hnlinux.net/fn</taglib-uri>
  <taglib-location>/WEB-INF/taglibs/fn.tld</taglib-location>
  </taglib>

  <taglib>
  <taglib-uri>http://www.hnlinux.net/sql</taglib-uri>
  <taglib-location>/WEB-INF/taglibs/sql.tld</taglib-location>
  </taglib>

  <taglib>
  <taglib-uri>http://www.hnlinux.net/fmt</taglib-uri>
  <taglib-location>/WEB-INF/taglibs/fmt.tld</taglib-location>
  </taglib>
(注意我的<taglib-uri>引用了http://www.hnlinux.net,呵呵,所以大家如果按照這樣設置的話,在jsp中引用jstl標簽是記得采用這樣寫<%@ taglib uri=http://www.hnlinux.net/core prefix="c" %>,可見這里配置是很靈活的隨便你取什么名字,只要在寫jsp的時候相對應就可以)

現在你就可以使用jstl來書寫你的jsp了.

三.連接mysql數據庫的配置
   1.下載 mysql-connector-java-5.0.0-beta.zip 將mysql-connector-java-5.0.0-beta-bin.jar復制到$Tomcat_home$/common/lib文件夾,(如果你不想使用數據連接池的話,可以放在 你的站點/WEB-INF/lib文件夾下)
 2.搞定了,你現在就可以使用連接數據庫的的相關語句了(這個是最簡單的,呵呵)

四.mysql連接池的配置.
 1.下載commons-dbcp-1.2.1.zip 解壓將commons-dbcp-1.2.1.jar復制到$Tomcat_home$/common/lib下(保證mysql的jdbc的驅動也在此目錄)
 2.修改$Tomcat_home$/cof/server.xml在context標簽內添加以下內容,如果沒有找到context標簽,注意在下面加上紅色的部分,蘭色部分根據自己情況修改,不用解釋了吧?
<Context path="/hasek" docBase="hasek"
        debug="5" reloadable="true" crossContext="true">
  <Resource name="hasek" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/hasek?autoReconnect=true"/>

</Context>
注意一點的事情是:<Context path="/hasek" docBase="hasek"... 中/hasek代表的是 你的站點
<Resource name="hasek
" 這個hasek代表的是你的連接池的名字,這個要和下面的web.xml里的內容相一致.
url="jdbc:mysql://localhost:3306/hasek?autoReconnect=true"/>中的hasek代表你的數據庫名字

3.修改 你的站點/WEB-INF/web.xml 在</webapp>標簽前添加以下內容:

  <description>MySQL Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>hasek</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
 4.測試代碼(連接池與jstl標簽測試)test.jsp

<%@ taglib uri="http://www.hnlinux.net/sql" prefix="sql" %>
<%@ taglib uri="http://www.hnlinux.net/core" prefix="c" %>

<sql:query var="rs" dataSource="hasek">
select * from hasek
</sql:query>

<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>

  <h2>測試成功</h2>
 
<c:forEach var="row" items="${rs.rows}">
    Foo ${row.id}<br/>
    Bar ${row.num}<br/>
</c:forEach>

  </body>
</html>
5.輸入http://localhost:8080/hasek/test.jsp看到測試成功字樣就說明你配置ok了



夏天的零度 2006-02-28 08:51 發表評論
]]>
[轉載]Tomcat 5.5.15 和SQLServer2000 SP3的連接池http://www.aygfsteel.com/dazern/articles/32727.html夏天的零度夏天的零度Mon, 27 Feb 2006 12:44:00 GMThttp://www.aygfsteel.com/dazern/articles/32727.htmlhttp://www.aygfsteel.com/dazern/comments/32727.htmlhttp://www.aygfsteel.com/dazern/articles/32727.html#Feedback0http://www.aygfsteel.com/dazern/comments/commentRss/32727.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/32727.htmlTomcat 5.5.15 和SQLServer2000 SP3基于SQLServer2000JDBC SP3 的連接池配制
一、準備
需要下載:
1. tomcat5.5.15
2. Tomcat5.5.15admin
3. SQLServer2000JDBC SP3或者jtds

安裝tomcat。并添加admin角色和用戶。
將jdbc驅動包放到tomcat_home\common\lib目錄下。
在MyEclipse建立一個新的Web項目。使用剛才配置的tomcat作為服務器。

啟動tomcat。

二、配置
打開tomcat。
 
登錄 Tomcat Web Server Administration Tool.


點擊左側的Data Sources。
 
在右側Available Actions下拉菜單中選擇Create New Data Source.
 
輸入
JNDI Name:
Data Source URL:
JDBC Driver Class:
User Name:
Password:
Max.Active Connections:最大活動連結數 ,0為不限 。
Max.Idle Connections:最大等待連結數 ,0為不限 。
Max.Wait for Connection:建立連接超時時間ms,-1為無限 。

注:使用SQLServer的官方JDBC驅動,Class=com.microsoft.jdbc.sqlserver.SQLServerDriver,URL=jdbc:Microsoft:sqlserver://127.0.0.1:1433;databaseName=aa;使用開源的驅動Jtds,Class=net.sourceforge.jtds.jdbc.sqlserver,URL=jdbc:jtds:sqlserver://127.0.0.1:1433/aa

輸入完畢,點擊“Save”按鈕保存。
 
點擊頁面右上側“Commit Changes”按鈕,保存剛才的設置。(這一步很重要哦!)

打開tomcat_home\conf\server.xml的< GlobalNamingResources></ GlobalNamingResources>中找到

    <Resource
      name="jdbc/mydbcp"
      type="javax.sql.DataSource"
      password="aa"
      driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
      maxIdle="2"
      maxWait="5000"
      username="aa"
      url="jdbc:microsoft:sqlserver://10.0.2.37:1433;databaseName=aa"
      maxActive="4"/>
這是JNDI的主要配置文件,可以不使用圖形界面直接寫入server.xml中。
在tomcat_home\webapps\dbcp\ META-INF\context.xml的<context></context>中填入上面的代碼。
如果更改了JNDI,則必須手動更改context.xml。

    <Resource
      name="mydbcp" 注:此處不同
      type="javax.sql.DataSource"
      password="aa"
      driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
      maxIdle="2"
      maxWait="5000"
      username="aa"
      url="jdbc:microsoft:sqlserver://10.0.2.37:1433;databaseName=aa"
      maxActive="4"/>

  <ResourceLink
    global="jdbc/mydbcp"
    name="jdbc/mydbcp"
type="javax.sql.DataSource"/>

重起tomcat。

連接方法:

    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource) envCtx.lookup("jdbc/mydbcp");
    Connection conn = ds.getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from systypes");
三、測試

測試實例:test.jsp

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.sql.*,javax.sql.DataSource,javax.naming.*"%>
<html>
 <head>
  <title>
   tomcat 連接池
  </title>
 </head>
 <body bgcolor="#ffffff">
  <h3>
   test
   <br>
   連接池3
  </h3>
  <%try {
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource) envCtx.lookup("jdbc/mydbcp");
    Connection conn = ds.getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from systypes");
    while (rs.next()) {%>

  <br>
  <%=rs.getString(1)%>
  <%}%>
  <%out.print("<br>Successful!成功!!\n");%>
  <%rs.close();
    stmt.close();
    conn.close();
   } catch (Exception e) {
    out.print("出現例外!" + e.getMessage());
    e.printStackTrace();
   }

  %>

 </body>
</html>

四、錯誤

錯誤1:Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
是沒有將sql jdbc driver包放在common\lib\目錄下。

錯誤2:Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.)
SQL數據庫補丁包的問題,如果訪問的數據庫是SP3,任何問題沒有。不是SP3就會出現上面的錯誤。

錯誤3:Name mydbcp is not bound in this Context
在context.xml中加入
<ResourceLink
    global="jdbc/mydbcp"
    name="jdbc/mydbcp"
type="javax.sql.DataSource"/>



夏天的零度 2006-02-27 20:44 發表評論
]]>
Tomcat5.5.12 + mysql5.0 +Eclipse連接池配置http://www.aygfsteel.com/dazern/articles/32721.html夏天的零度夏天的零度Mon, 27 Feb 2006 11:44:00 GMThttp://www.aygfsteel.com/dazern/articles/32721.htmlhttp://www.aygfsteel.com/dazern/comments/32721.htmlhttp://www.aygfsteel.com/dazern/articles/32721.html#Feedback1http://www.aygfsteel.com/dazern/comments/commentRss/32721.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/32721.html
1.Tomcat5.5.12中沒有admin模塊,需要讀者自行下載

2.Tomcat中配置如下
        JNDI Name:    jdbc/mysql
            Data Source URL:  jdbc:mysql://202.118.133.88/xscj  
            JDBC Driver Class:   org.gjt.mm.mysql.Driver
            User Name:    root
            Password:     ********
            Max. Active Connections:    4
            Max. Idle Connections:    2
            Max. Wait for Connection:    500
            Validation Query:  
    注:
        1.jdbc/mysql 前綱的jdbc也可以換成其它的, mysql為連池名,可任意起,在下文中注意使用
          2.jdbc:mysql://192.168.0.16/xscj   xscj為對應的數據庫名
              也可以換成jdbc:mysql://localhost/xscj        
         3.JDBC Driver Class : com.mysql.jdbc.Driver   jdk中自帶
       4.User Name:為Mysql中數據庫管理員名

3. 下面是最關鍵的一點  

D:\Tomcat 5.5\conf\context.xml

<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
        
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
<Resource
    name="mysql/xscj"
    type="javax.sql.DataSource"
    password="kingsoft88"
    driverClassName="com.mysql.jdbc.Driver"
    maxIdle="2"
    maxWait="5000"
    username="root"
    url="jdbc:mysql://202.118.133.88:3306/xscj"
    maxActive="4"/>

</Context>

應相應的字段真加對了就可以了。

4.在Eclipse中編譯時加入Tomcat 的DBCP和Pool包就不會有問題了.
測試程序如下:
<html>
<head>
<title></title>
<%
   out.print("開始測試:"+"<br/>");
   DataSource ds = null;
   Connection con=null;
   try{  
           Context initCtx = new InitialContext();
           Context ctx = (Context) initCtx.lookup("java:comp/env");
                  //這里的數據庫前文提及的Data Source URL配置里包含的數據庫。
           ds = (DataSource)ctx.lookup("jdbc/xscj");
           con=ds.getConnection();
   Statement stmt = con.createStatement();
   String strSql = "select * from xs";                       //表中的字段讀者自行添加
   ResultSet rs = stmt.executeQuery(strSql);
   while(rs.next()){
      out.print(rs.getString(1)+"<br/>");                
     }
        rs.close();
        stmt.close();
       con.close();        
    out.print("我的測試結束");
   }
   catch(Exception ex){
       out.print("出現例外,信息是:”+ ex.getMessage());
    ex.printStackTrace();
   }
%>
</head>
<body>
</body>
</html>

總結:以上步驟均十分關鍵,如果有誤對應錯誤如下

1、第一步錯誤,報錯
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

2、第三步錯誤,報錯
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

3、第四步錯誤,報錯
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket

如果有上述錯誤,請檢查對應步驟是否正確實施

夏天的零度 2006-02-27 19:44 發表評論
]]>
[轉載]Tomcat5.5.12配置詳解http://www.aygfsteel.com/dazern/articles/32719.html夏天的零度夏天的零度Mon, 27 Feb 2006 11:34:00 GMThttp://www.aygfsteel.com/dazern/articles/32719.htmlhttp://www.aygfsteel.com/dazern/comments/32719.htmlhttp://www.aygfsteel.com/dazern/articles/32719.html#Feedback0http://www.aygfsteel.com/dazern/comments/commentRss/32719.htmlhttp://www.aygfsteel.com/dazern/services/trackbacks/32719.html


      今天下載了5.5.12版的TOMCAT,折騰了半天才知道TOMCAT5.0.28之后就沒有了默認的admin模塊,還以為我的配置哪出錯了(花了半小時沒找出原因:()。下面是網上當的一些關于TOMCAT配置方面的技巧,對相關的配置方法在沒有改動原文的同時也做了適當修改,已紅色字標記。目前使用的是最新的jdk為1.5+tomcat5.5.12這里只給出簡單的配置。
JDK1.5:
JAVA_HOME=c:\j2sdk1.5
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(.;一定不能少,因為它代表當前路徑)
path=%JAVA_HOME%\bin

Tomcat 5.5.12:
CATALINA_HOME:c:\tomcat
CATALINA_BASE:c:\tomcat
TOMCAT_HOME: C:\Tomcat
修改classpath,classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\common\lib\servlet.jar; 啟動tomcat,在IE中訪問http://localhost:8080,如果看到tomcat的歡迎頁面的話說明安裝成功了。

下面可能會是經常出現和遇到的問題:
1.下載http://www.eu.apache.org/dist/jakarta/tomcat-5/
這里注意,在jakarta-tomcat-5.0.28.exe以前是有默認的admin模塊,在jakarta-tomcat-5.5.9.exe則沒有安裝默認的admin模塊,這時http://127.0.0.1:8080/admin打開時則會出現
Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it.
因此我們現在需要下載"admin"package 包
把jakarta-tomcat-5.5.x.zip 與 jakarta-tomcat-5.5.x-compat.zip 與 jakarta-tomcat-5.5.x-admin.zip三個文件解壓在同一個目錄中(如果使用jdk1.4,才需要compat.zip用jdk1.5就可以免了這個。) 如果使用的是JDK1.5+tomcat5.5.12只需要將jakarta-tomcat-5.5.x-admin.zip文件解壓到TOMCAT目錄即可.

2.修改jakarta-tomcat-5.5.x\conf\tomcat-users.xml.
添加管理員賬號lizongbo,密碼為lizongbopass.(一般在安裝Tomcat的同時已提示輸入用戶名及密碼,如果有設置此處可不做修改。)
新xml如下:

有時在%CATALINA_HOME%\server\webapps\admin\WEB-INF\web.xml里面也要做些修改

Tomcat Server Configuration Security Constraint

Protected Area

*.jsp
*.do
*.html

admin

FORM
Tomcat Server Configuration Form-Based Authentication Area
/login.jsp /error.jsp



The role that is required to log in to the Administration Application

admin


無論是 Authetication (身份驗證還是 Authorization ( 權限管控都只有設置相關的admin ROLE,當你想要新增或修改相關的AA, 就必須修改這一個文件,來符合你的環境.

3.修改jakarta-tomcat-5.5.x\conf\server.xml來解決編碼問題。
(給Connector 添加URIEncoding參數,參考http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx)
(可以設置成GB18030)
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="200"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK"
compression="on" compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"/>

enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="GBK"/>
(這個還是比較頭痛的問題,試了幾種方法都不是太理想,有待繼續解決,maxHttpHeaderSize="8192")

4.啟用支持gzip壓縮.
(http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&i=81169)
添加下列屬性
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"

5.設置虛擬主機。
在jakarta-tomcat-5.5.x\下建立文件夾vhost\www.mydomain.com。
然后修改jakarta-tomcat-5.5.x\conf\server.xml

6.添加數據庫驅動,更新mail.jar和actiovation.jar
復制mysql-connector-java-3.0.16-ga-bin.jar,pg74.215.jdbc3.jar到 jakarta-tomcat-5.5.x\common\lib\
還有javamail 1.3.2的mail.jar,jaf-1_0_2的 activation.jar
msSQl 2000 JDBC sp3,msbase.jar,msutil,jar,mssqlserver.jar

7.配置SSL
參考 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/ssl-howto.html
D:\j2sdk1.4.2_06\bin>%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
輸入keystore密碼: lizongbossl
您的名字與姓氏是什么?
[tomcat5.5.x]: tomcat5.5.x
您的組織單位名稱是什么?
[jakarta]: jakarta
您的組織名稱是什么?
[apache]: apache
您所在的城市或區域名稱是什么?
[hzcity]: hzcity
您所在的州或省份名稱是什么?
[gdp]: gdp
該單位的兩字母國家代碼是什么
[CN]: CN
CN=tomcat5.5.x, OU=jakarta, O=apache, L=hzcity, ST=gdp, C=CN 正確嗎?
[否]: y

輸入的主密碼
(如果和 keystore 密碼相同,按回車):

(必須密碼一致,因此直接回車)
然后再把userhome(例如:C:\Documents and Settings\lizongbo\)下的.keystore復制到
tomcat的conf\目錄下。
(例如:D:\jakarta-tomcat-5.5.x\conf\.keystore
配置jakarta-tomcat-5.5.x\conf\server.xml
加上
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="conf/.keystore"
keystorePass="lizongbossl">

8.禁止文件目錄列表,
修改jakarta-tomcat-5.5.x\conf\web.xml,把listing設置為false

default
org.apache.catalina.servlets.DefaultServlet
debug 0
listings true
1

9.指定了自己的javaEncoding
(參考 http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html

jsp
org.apache.jasper.servlet.JspServlet

fork false


javaEncoding GB18030


xpoweredBy true

3

10.添加rar,iso等的mime-type映射
避免在瀏覽器里直接打開。

mht
text/x-mht

rar
application/octet-stream

iso
application/octet-stream

ape
application/octet-stream

rmvb
application/octet-stream

ico
image/x-icon

10.1對html靜態頁面設置編碼

htm
text/html;charset=gb2312

html
text/html;charset=gb2312

11.添加welcome-file-list,并調整順序。

index.jsp
index.html
index.htm
default.html
default.htm
default.jsp



夏天的零度 2006-02-27 19:34 發表評論
]]>
主站蜘蛛池模板: 海盐县| 蓝田县| 博白县| 五大连池市| 海门市| 清新县| 高雄市| 西昌市| 太谷县| 南陵县| 济宁市| 十堰市| 开江县| 同德县| 栾城县| 中超| 齐齐哈尔市| 梧州市| 吴江市| 尉犁县| 平乐县| 东台市| 夏河县| 鄄城县| 安新县| 台北市| 金门县| 当雄县| 武宁县| 丰顺县| 贺兰县| 南汇区| 五指山市| 宁蒗| 汪清县| 新绛县| 阿拉善右旗| 长丰县| 榆树市| 栾城县| 梁河县|