FAQ 2 - [email protected]

*如何使用JavaBean
需要把JavaBean.class文件拷貝到對應的文件夾,Tomcat不會編譯java文件

*爲什麼JDBC連接Oracle數據庫的時候,update ResultSet 數據庫失敗?
見./lib/關於ResultSet接口插入數據的問題.htm

*JSP處理表單的時候讀入的中文出現亂碼,用如下方式解決:
見/lib下的JSP亂碼解決辦法

*Tree View developed in Javascript(Javascript創建樹形目錄)
see lib/nanotree.htm and lib/nanotree.rar

*如何在linux上添加Oracle "thin"模式的JDBC驅動程序?
STEP1 將對應的jar文件拷貝到jdk的庫目錄中
STEP2 在/etc/profile中設置CLASSPATH,如下所示:
CLASSPATH=/home/sonic/jdk/j2sdk1.4.2_03/lib/tools.jar:/home/sonic/jdk/j2sdk1.4.2_03/lib/dt.jar:/home/sonic/jdk/j2sdk1.4.2_03/lib/classes12.jar:/home/sonic/jdk/j2sdk1.4.2_03/lib/ojdbc14.jar:/home/sonic/jdk/j2sdk1.4.2_03/lib/nls_charset12.jar:.
# JAVA_HOME=/home/sonic/jdk/j2sdk1.4.2_03
# PATH=${PATH}:/home/sonic/jdk/j2sdk1.4.2_03/bin
export CLASSPATH

*如何爲TOMCAT添加JDBC驅動程序?
STEP1 將對應的jar文件拷貝到[CATALINA_HOME]/common/lib下
STEP2 重新啓動tomcat

*如何配置Tomcat的連接池?

1 sever.xml中對應的<Context><Resource></Resource></Context>中添加Resource, 這裏(http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html)有詳細描述
2 webapp的web.xml中描述對應的資源,這裏(http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html)也有
3 重新啓動Tomcat服務器就可以了
注意:
- 一定要在正確的Context中加入Resource
- 一定要保證jsp中,WEB-INF/web.xml中的<res-ref-name>名和<Context>中的<Resource name="..">保持一致
-  好像在4.1.18版本以下第2步並不需要
- 可以用tomcat自帶的administrator工具來做可以提高效率

還有一種方式:在<GlobalNamingResources></GlobalNamingResources>中加入Resource,然後再在對應的Context中用ResourceLink引用即可。方法與上類似。


- 用Tomcat的Administrator工具,在對應的webapp中添加一個DataSource
- 在對應的sever.xml的<Context><Resource></Resource></Context>中可以手工更改設置
  - 連接池管理器類名
  - 連接池資源的Auth屬性
  - 連接池的各種參數
- 重新啓動Tomcat服務器就可以了
注意:
1.一定要在正確的Context中加入DataSource的Resource
2.一定要保證jsp中,WEB-INF/web.xml中的<res-ref-name>名和<Context>中的<Resource name="..">保持一致
3.好像在4.1.18版本中<res-ref-name>並不需要

./lib/tomcat-dbcp-config.zip中包含成功配置的三個文件:server.xml和webapp

還有一種方式:
在globalnaming中加入Resource,然後再在對應的Context中用ResourceLink引用即可。

-Tomcat 4.1.18版本(可能主版本爲4的所有Tomcat都是)在安裝的時候,若鉤上“安裝成Windows Service”的話,
啓動以後右下角不會出現Tomcat的圖標。但是服務器實際上已經啓動起來了,系統進程名爲Tomcat.exe

*配置CVS服務器的方法:
./lib/CSDN_配置CVS服務器和客戶端完全解析.htm

*使用文件目錄服務的時候,無法initialContext的問題怎麼解決?

因爲包含com.sun.jndi.fscontext.RefFSContextFactory的fscontext.jar包不是標準包,
需要手工加入classpath,{J2SDKEE}/imp//lib/fscontext.jar就可以了

*爲什麼lib/ex2.html中的javascript代碼不能執行?
該代碼中有幾個錯誤:
-忘記給函數加“function”標識
-document.getElementById()調用給的是元素的id,而不是name!!!

*在作"TreeView"時遇到的問題:
<a onClick="Toggle(this)"><img src="plus.bmp">root </a>
<div style="display:none">abcdefggg</div>

<a onClick="Toggle(this)"><img src="plus.bmp">root</a>
<div style="display:none">abcdefggg</div>

這兩段HTML代碼有什麼不同??

前者調用this.nextSibling.style.display 可控制<div>的屬性,但對後者調用則找不到對象??
這是怎麼回事呢?root後面的空格起什麼作用?

*如何解決動態加載iframe時,窗口大小隨內容變化?
見/lib/container.html

*如何解決Tomcat 5.0.24 中用不了Session的問題?
Tomcat 5.0.24中,用自帶的web發佈工具時,處理webapp的session時會有問題。workaround:如果不用web
發佈工具就可以了參見/lib/session.html

*頁面上的中文出現亂碼時怎麼辦?
用<%@ page  contentType="text/html;charset=gb2312"%>和
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
定義頁面的字符集。第一個好像對jsp也有效。所以用它比較好。
注意使用頁面跳轉<jsp:forward>的時候,前面的頁面設置session變量時候用到不正確的
字符集會使跳轉目標的中文顯示亂碼。

*如何配置Tomcat爲servlet執行環境?
http://www.itpub.net/showthread.php?s=&threadid=226990

*如何使用Eclipse調試servlet?
http://www.sysdeo.com/eclipse/tomcatPlugin.html

*如何使用Eclipse調試JSP?
見lib中的Eclipse 3 + Lomboz 3 + Tomcat 5三篇。另外注意以下幾個問題:
-Tomcat中XML配置文件XML標籤屬性區分大小寫
-Tomcat5.0.27在使用中有問題(啓動Tomcat服務器失敗)Tomcat5.0.24可以和Eclipse3M09版本正常使用。

*如何在Servlet中調用JSP?
-見lib/【如何在servlet裏調用JSP Errorpage】

*爲什麼在linux+tomcat的環境中,表單輸入項中若有中文的話,讀入之後變成亂碼?
-<connector ... URIEncoding="GBK"/>
                --------------------->有這個就可以了
*注意POST和GET方法對於表單輸入的處理不一樣。中文出現亂碼的情況也不同,注意研究。本方法對GET方法有效

*如何向Oracle數據庫表中導入excel數據?
STEP1 用OFFICE將.xls文件轉換成文本文件
STEP2
方法一
1.編寫錄入控制文件,內容如下所示:

filename:input.ctl

load data
infile 'test.txt'  //--指定要導入的文件
append into table sonic.test //--指定要導入的表
fields terminated by X'09' //--域值由製表符分割
(id,username,password,sj) //--表列的屬性

2.用如下的命令將數據導入:
C:>sqlldr userid=sonix/sonix@oracle_162.105.130.50 control=input.ctl log=load_date.log

方法二
自己寫一個Java程序將數據導入

*安裝lirc的問題:
- 如果不能make的時候出現如下錯誤:
[...]
make[3]: Entering directory `/usr/src/lirc-0.6.4/drivers/lirc_serial'
DIR=`pwd`; (cd /usr/src/linux/; make SUBDIRS=$DIR obj-m=lirc_serial.o modules)
/usr/src/linux/scripts/pathdown.sh: TOPDIR: parameter null or not set
make[4]: Entering directory `/usr/src/linux'
make[4]: *** No rule to make target `lirc_serial.o', needed by `modules'.
[...]
     
This means that you did not set up and compile your current kernel from the given Linux kernel sources. Recompile your kernel and reboot before proceeding to compile LIRC. There is no other reliable way to get working LIRC modules than compiling your kernel yourself. During compilation LIRC uses the kernel sources to get the current kernel configuration.
- lirc暫時不支持2.6的kernel
- 運行mode2出現下列錯誤:
mode2: error opening /dev/lirc
mode2: No such device
很可能是因爲模塊沒有載入內核:/lib/modules/2.4.20/ 用insmod添加

- 運行mode2可以測試是否接受成功
- 運行irrecord可以學習遙控器
- 運行irw可以檢測遙控碼
- 運行rc可以發送已知遙控碼
- SONY攝像頭的遙控碼需要重複發送遙控接收端才能夠正確收到每個碼的間隔也各不相同

*如何跨網段用exceed連接服務器?
- make sure 'Xaccess' file allows any host to get a login window[http://www.hummingbird.com/support/nc/exceed/ex60237.html?cks=y]
-make sure 'xdm-config' file allows any host to connect
- 本地啓動XServer
- ssh2服務器,啓動xdm連接Xserver

*linux 不能啓動了怎麼辦?
- 用光盤1的Rescure功能可以進入維護模式,維護模式中,所有文件系統都在內存和光盤上,
可以用mkdir接mount命令將磁盤掛到當前文件系統上進行操作,如修改配置文件等等。

*編譯內核以後網卡不支持怎麼辦?
- 在make xconfig命令之後選擇-->Network device support-->10/100M Ethernet-->選擇自
己需要的設備。再make dep/make clean/make bzImage/make modules/make modules_install

*使用struts+JSTL的時候,做好的中文properties文件,其中的中文value在頁面顯示亂碼,怎麼辦?
- 用native2ascii -encoding gb2312 <input-file> <output-file>處理properties文件即可,native2ascii是jdk自帶工具
見lib/Java 相關編程技術樂園 - struts中文問題,struts國際化問題的終極解決方案.htm

*爲什麼使用"<html:text>、<html:password>"等標籤時報錯?
- <html:text><html:password>表籤需要嵌入到html:text中才可用。http://struts.apache.org/userGuide/struts-html.html

*爲什麼使用Java中的HashMap的時候,如果用自定義對象作爲key,查不到對應的值?
- 在自定義的類中重載Object.hashCode()和Object.equals()兩個方法,第一個用於計算對象的哈希值,後面一個用於判斷兩個哈希值相同的對象是否真正相同。

*在使用tiles:put標籤的時(<tiles:put name="tree" value="welcomeTree.jsp"/>)爲什麼不能將需要的內容插入?
爲了插入一個jsp頁面,value="...":必須使用絕對路徑<tiles:put name="tree" value="/welcome/welcomeTree.jsp"/>

*如何向select對象中動態插入值?
select.html

*如何通過JavaBean或JSP的request對象獲得<select multiple ...>提交的數據?
用JavaBean的String [] 屬性或者request.getParameterValues()方法即可獲得,注意提交的只有
selected屬性的options

*如何實現改變一個下拉菜單,另一個下拉菜單的內容隨之變化(從數據庫中取數據),就像www.smth.org的左邊?
roomselect.jsp,tst2.jsp,roomselect2.jsp,tst3.jsp

*爲什麼有時候在用sysdeo的eclipse tomcat plugin調試Servlet時找不到源代碼?
檢查window->preferences...->Tomcat->Source Path,當前的項目是否已經勾上?

*如何實現通過網頁向指定用戶發郵件?
用sun的javamail包

*RBDatabase pool中checkquery是必需的

*爲什用JSTL的fmt:message時${pageScope.var-a}不能正確顯示?
-pageScope等,變量命名規則不允許hyphen.

*如何生成.war文件?
>cd XXXX
>jar -cvf XXXX.war *
XXXX=app-root

*在tomcat中使用javamail時遇到javax.mail.NoSuchProviderException: smtp怎麼辦?
delete the "mail.jar" in <tomcat-dir>/common/lib/, whose version is probably different with what you put in WEB-INF/lib/, or
delete what you put in WEB-INF/lib, let your application use tomcat's "mail.jar"
the first one sounds awkward, second is better.

*如何在CVS創建branch?
lib/見cvs-branch-tag.doc
*如何配置tomcat的SSL?
www.apache.org->找tomcat的document的how-to
注意通過https://xxxxx:8443來訪問
還有一點要注意:關閉不支持https的代理服務器
*如何使得url欄中不顯示錶單內容?
表單用"POST"方法提交而不用"GET"方法提交
*如何用Java獲得Http內容?
用Jakarta的http client
*無法將tomcat端口改到80?
用root帳戶啓tomcat即可80端口訪問權限要求root
*重啓xinetd的方法
/sbin/service xinetd start/stop/restart
*helix DNA server 在fedora Core3 for i386上可以安裝但是運行後客戶端無法與之通信
helix DNA Server 10.0.1在RH Linux 9/Windows XP/RH Linux AS上可以正常運行
懷疑該版本的DNA Server不支持2.6的內核(OK)
*helix DNA Server 11可以從CVS上check out出來但是20050105的版本在linux2.4.21/gcc3.3.3編譯出錯。
-源代碼server/engine/core/platform/unix/main.cpp 中把stub_errno函數給註釋掉OK
-按照build.out的步驟biuld剩下的部分OK。
-依然不支持IPv6
*SQL語言中的大小寫模糊查詢
upper() lower()
*gtk-config找不到?
從gtk2.0起,gtk-config不再使用,改用pkg-config
*ram文件是什麼?
ram文件實際上就是地址文件。我們把實際文件的地址寫到ram文件中,然後在網頁上鍊接ram文件。例如rock.ram的內容就是:rtsp://www.5dmedia.com:554/rock.rm,而上面的鏈接就改成http://www.5dmedia.com/rock.ram
*爲什麼我的VLC-8.0播出來的東西,Windows Media Player不能看?
Make sure your Windows media player version is higher than or equal to 9.0.
Make sure your contents are encoded in 'DIV3' format.
Make sure your contents are encapsulated in 'ASF' format
More information can be found in VLC's document.
*如何將media player嵌入頁面?
見lib/計算機世界網-嵌入式流媒體web頁面實現.htm
*如何用java進行C/S網絡編程?
用ServerSocket類,見lib/Matrix-與Java共舞 - java技術專欄.files
*如何在java中調用那些只能在command line[windows]/shell[unix like systems]中執行的程序?
用Runtime.exec(String [] cmds)方法來實現
Windows:cmds = {"cmd.exe","/C", "notepad.exe"};
Unix:cmds = {"/bin/sh","-c","/sbin/ifconfig>ifconfig.txt"};
具體實現方法參見:lib/Java 技術論壇 - 使用Runtime類別開啟命令列問題
==========================================================================================
*How to install skyeye?
- download skyeye from ftp://166.111.68.183/pub/embed/skyeye,
- download vnet from ftp://166.111.68.183/pub/embed/skyeye/src/vnet
- install vnet. NOTE: update Makefile by adjusting the HEADER_DIR line for your situation before compiling.
- download and install arm tool chain from ftp://166.111.68.183/pub/embed/uclinux/soft/tools/arm
- install skyeye by source or binary.
- download ucosii tester to test your installation.
*My program needs dynamic libraries in directory other than '/usr/lib' or '/lib', what can I do?
- set "LD_RUN_PATH" and "LD_LIBRARY_PATH" environment variable to the directory contains your libraries and restart your program
*When compiling 'xmms', configure tool complains that no glib or gtk is available, but it is indeed installed!
- make sure the development package,instead of the runtime libraries, is installed!
*How to add ipv6 support on HHARM2410 board???
Currently, I tried it this way:
-recompile the kernel with ipv6 support.
-download the kernel and run it.
-ping its Global Link address. OK
*Why inetd/xinetd?
-unix like systems have a lot of program that listening on ports.
-large memory will consumed if let them waiting by them self
-inetd/xinet listen on this port and call them.
*Why 'mount nfs-server:/nfs-folder' complains 'Permission denied'?
- A couple of things to keep in mind with NFS: permissions are handled by UID.
  It is very beneficial to ensure that a user on the client has the same UID
on the server. Otherwise the permissions will just confuse you.  If you are
just using root, and using the no_root_squash option on every mount, you don't
have to worry about this.
*Why my DNS Server on Linux doesn't work??
Try BIND9, which supports IPv6 nameing query.http://www.isc.org
*Why gcc complains 'storage size of `xxx' isn't known'
-Make sure the struct type defining xxx is correct.
*I'm using vlc 0.8.1, I want to play a stream sent to my udp port:5555 on IPv6. I checked the []force IPv6 checkbox in 'opening network stream' dialog, but the console prints 'main input error: no suitable access module for `udp://@[::]@:5555'', why?
-change '@[::]@:5555' to '@[::]:5555' in the command text box of 'open network stream' window, then play.
*How to stream video on IPv6?
-To relay stream, use command like this:
  vlc udp://@[::]:5555 --sout '#transcode{vcodec=DIV3,vb=1024,scale=1}:duplicate{dst=display,dst=std{access=mmsh,mux=asfh,url=:7777}}'
-To publish stream, use command like this:
  vlc v4l:/dev/video:norm=pal:size=320x240:channel=1:audio=0 --sout '#transcode{vcodec=mp4v,vb=512,acodec=mpga,ab=192}:duplicate{dst=display,dst=std{access=udp,mux=ts,url=238.1.1.238:1234}}'
*Why my 'Timer' complains about 'Cancel again' Exception?
- a Timer can only be cancelled once, even if it is scheduled again after the first cancel()
- note: if a Timer hasn't been stopped explicitly, the timer thread will never will never end.
*Why my fedora linux has no source code installed with 'installing everything'?
- Fedora no longer ships with the kernel-source RPM. You must install it separately(http://www.mjmwired.net/resources/mjm-fedora-fc3.shtml#kernelsrc).
*Why the LIRC rpm package along with Fedora Core 3 doesn't work with my home-brewed serial ir-sender/recevier?
- " The default binary build of this package will only work with the Pinnacle PCTV serial remote. if you have a different device, your will probably need to recompile the source RPM changing the "--with-driver=" configure option to your device. if your remote requires special kernel modules to run, I guess you're stuck having to recompile a kernel and recompile lirc manually to get the modules!" - http://dag.wieers.com/packages/lirc/
*How to make lirc 0.6.0 work on Linux with kernel 2.6.x?
http://www.home.no/zkronk/lirc.html
*Why sirs doesn't work on my computer?
- your computer may be too fast or too slow, adjust the gSUTL(Sirs UART Transmitter Latency) and gDutyCycle for your system: the faster your computer is, the smaller the number should be, ther are several working example for reference:
COMPUTER gSUTL gDutyCyle
PIII450MHz 400 50
PIV3.2GHz 0 55
*Why 'try_module_put(THIS_MODULE)' doesn't work in my driver: compilation
complains that the symbol is not linked
- currently don't know why
*Why my CyberLink UPnP Control.Point doesn't identify online UPnP Device?
- If you are using JDK 1.5.0, make sure you've chosen a right UPnP.setEnable(XXX) configuration for your device:
 DEVICE   ControlPoint
 USE_ONLY_IPV6_ADDR USE_ONLY_IPV6_ADDR
 USE_ONLY_IPV4_ADDR USE_ONLY_IPV4_ADDR
NOTICE:
<BLOOD EXPERIENCE I>if you are using JDK 1.4.2 or lower version, it is equal to that you are using JDK 1.5.0 with 'USE_ONLY_IPV4_ADDR'
<BLOOD EXPERIENCE II>if you are running an IPv6 ControlPoint on Fedora Core 3, the CyberLink's UPnPSDK won't work!!!I'm gonna report this problem to RedHat!Ethereal show that after an IPv6 enabled UPnPDevice is started on FC3, only 6 'byebye' SSDP package are multicasted.

*How to get working path on servlet?
-Servlet.getServletContext().getRealPath("/");

*Why 'ssd' can send CORRECT infrared code in terminal(real terminal), but
emits INCORRECT infrared code in X?
- my Fedora Core3 with kernel 2.6.10-SMP on Pentium 4 HT(HyperThreading) has this problem, but after my recompile the same kernel source and make a 2.6.10 signal CPU image, this problem disappears.
===========================================================================================
* linux下的sniffer工具是什麼?
Ethereal,tcpdump都可以
* 爲什麼用htonl(portnumber)得到的結果不正確?
注意htonl是處理8字節的,htons是處理4字節的。
* 如何在CEdit裏面換行?
lib下
* MFC應用程序退出
發送WM_CLOSE消息即可
* 爲什麼我用select()調用總是返回10022錯誤?
每次select()之後最好重置被select的集合set!!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章