锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
渚嬪:Tomcat瀹夎鍦―:\jakarta-tomcat-5.5.9
姝ラ1錛氭妸JDK j2sdk1.4.2_08 copy 鍒癟omcat鐨勫畨瑁呯洰褰曚笅
D:\jakarta-tomcat-5.5.9\j2sdk1.4.2_08
姝ラ2錛氬湪D:\jakarta-tomcat-5.5.9\bin鐩綍涓嬭緗畇tatup.bat鍜宻hutdown.bat
set JAVA_HOME=%CATALINA_HOME%\j2sdk1.4.2_08
娉ㄦ剰浣嶇疆 蹇呴』鍦–ATALINA_HOME璧嬪煎悗
綞撻亷鍒嗘瀽鏁寸悊錛屾垜鍊戠櫦鐝懼晱欏屽嚭鍦?QueryString 鐨勮В鏋愶紝浠ュ墠鍦?Tomcat 4.x 鏅備唬錛岀劇璜?SUBMIT 鏅傛帯鐢?GET or POST錛孴omcat server 灝?parameters 鐨勮檿鐞嗛兘鎺$敤鐩稿悓鐨勭法紕鹼紝浣嗗湪 Tomcat 5.x 鐗堬紝涓嶇煡浣曟晠錛屽嵒灝?QueryString 鐨勮В鏋愮崹绔嬪嚭渚嗭紝鐩墠紕鴻獚錛孎orm 鐨?Method 鎺$敤 GET 鍙婄洿鎺ュ皣鍙冩暩瀵湪 URL 涓婄殑涓枃錛屼笂鍌沖埌 Tomcat 鏅傦紝鐒¤珫濡備綍杞夌⒓錛岄兘鏈冭畩鎴愪簜紕鹼紝閭f曚綘浜嬪厛浣滈亷 URLEncode 涔熶竴妯c?
綞茬珯涓婏紝鏈変漢閲濆皪閫欏嬪晱欏岋紝寤鴻灝囨墍鏈変腑鏂囨敼鎺$敤 base64 綬ㄧ⒓錛屽埌浜?server 涓婏紝紼嬪紡灝囪嚜琛屽湡 base64 decode 鍥炰締錛岀⒑淇濅腑鏂囦笉鏈冪櫦鐢熷晱欏屻傞欐ǎ浣滄硶鐣剁劧鍙互瑙f焙閫欏嬪晱欏岋紝浣嗘槸鎵鏈夌恫闋佽畩鎴愰檺瀹氳鎺$敤 POST錛屼笖紼嬪紡璦▓甯闅ㄦ檪鍒嗘竻妤氾紝閭e嬪弮鏁告槸鎺$敤 GET 涓婂偝錛岄偅鍊嬪弮鏁告槸鎺$敤 POST 涓婂偝錛岀劧寰屽啀閲濆皪涓嶅悓鐨勬柟寮忔帯鐢ㄤ笉鍚岀殑瑙f瀽錛岄欐ǎ鐨勭▼寮忎竴榛炲厭縐繪鎬ч兘娌掓湁錛屾洿鍒ユ彁璺ㄥ鉤鍙般佽法鍦嬮殯瑾炶█浜嗐?
鐮旂┒ Tomcat 鐨勬枃浠跺強鍘熷紕鹼紝鎴戝戞壘鍒頒簡鍟忛鎵鍦ㄥ強瑙f焙鐨勬柟娉曪紝鍙湁鎸夎憲浠ヤ笅鐨勪綔娉曪紝鎵嶈兘浣?Form submit 鐨勮硣鏂欏畬鍏ㄦ寜钁?ISO8859-1 鐨勭法紕鹼紝鐣剁劧錛岃嫢鏄叏鐓ц憲 Tomcat 鐨勬枃浠惰鏄庡幓浣滐紝鑲畾閭勬槸涓嶈錛屼綘閭勬槸寰楀姞涓婇欏嬪弮鏁稿埌 server.xml 涓墠琛屻?
瑙f焙鏂規
璜嬪厛鐮旂┒ $TOMCAT_HOME/webapps/tomcat-docs/config/http.html 閫欏嬭鏄庢獢錛屾摲閷勯噸榛炲涓嬶細
URIEncoding錛歍his specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.
useBodyEncodingForURI錛歍his specifies if the encoding specified in contentType should be used for URI query parameters, instead of using the URIEncoding. This setting is present for compatibility with Tomcat 4.1.x, where the encoding specified in the contentType, or explicitely set using Request.setCharacterEncoding method was also used for the parameters from the URL. The default value is false.
涓婅堪浜屽?Tomcat 鍙冩暩錛屾槸璦畾鍦?server.xml 涓殑 http <Connector /> 鍗濉婏紝瑕佽В姹?QueryString 涓枃璁婃垚浜傜⒓鐨勫晱欏岋紝浣犲繀闋堣嚦灝戣ō瀹氶欎簩鍊嬪弮鏁稿叾涓箣涓銆?
URIEncoding 璜嬭ō瀹氱偤 URIEncoding="ISO-8859-1" 鎸囧畾鐐?"ISO-8859-1" 綬ㄧ⒓錛岃畵 QueryString 鐨勫瓧鍏冪法紕艱垏 post body 鐩稿悓銆?
useBodyEncodingForURI 閫欐槸鐢ㄤ締鐩稿 Tomcat 4.x 鐗堢殑錛岃ō瀹氱殑鍊兼槸 "true" or "false"錛屾剰鎬濇槸鎸?"瑕佷笉瑕佽畵 QueryString 鑸?POST BODY 鎺$敤鐩稿悓鐨勫瓧鍏冪法紕??"錛岃嫢鏄ō鎴?true錛岄偅涔熷彲閬斿埌 "ISO-8859-1" 綬ㄧ⒓鐨勯渶姹傘?
寤鴻錛屾帯鐢?URIEncoding 鐨勮ō瀹氾紝鐣㈢珶 useBodyEncodingForURI 鐨勪綔娉曟槸鐐轟簡鐩稿 Tomcat 4.X銆備笉閬庤嫢鐓у師鏂囩殑瑾槑錛岀悊璜栦笂閫欎簩鍊嬪弮鏁擱兘涓嶈ō錛孴omcat 涔熻┎鎺$敤 "ISO-8859-1" 鐨勭法紕鹼紝閭g偤浠楹奸倓鏄渻鏈夊晱欏屽憿 ? 鎴戝戠敱 Tomcat Source Code 渚嗙湅灝辨竻妤氫簡銆?/FONT>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29// 閫欎竴孌電⒓鏄?Tomcat 鐢ㄤ締瑙?QueryString 鐨勭▼寮忥紝
// 鍦?org.apache.tomcat.util.http.Parameters 閫欏?class 瑁°?/FONT>
private String urlDecode(ByteChunk bc, String enc)
throws IOException {
if( urlDec==null ) {
urlDec=new UDecoder();
}
urlDec.convert(bc);
String result = null;
if (enc != null) {
bc.setEncoding(enc);
result = bc.toString();
}
else {
CharChunk cc = tmpNameC;
cc.allocate(bc.getLength(), -1);
// Default encoding: fast conversion
byte[] bbuf = bc.getBuffer();
char[] cbuf = cc.getBuffer();
int start = bc.getStart();
for (int i = 0; i < bc.getLength(); i++) {
cbuf[i] = (char) (bbuf[i + start] & 0xff);
}
cc.setChars(cbuf, 0, bc.getLength());
result = cc.toString();
cc.recycle();
}
return result;
}
璜嬬壒鍒ユ敞鎰忕磪鑹插崁濉婏紝鐣?Tomcat 鐧肩従 QueryString 涓︽矑鏈夎ō瀹?encode 鏅傦紝涓﹂潪鍍忔枃浠朵腑鎵瑾爯璦帯鐢?ISO-8859-1 鐨勭法紕鹼紝鑰屾槸鐢ㄤ竴孌?fast conversion 渚嗚檿鐞嗭紝鎵嶆渻閫犳垚涓枃鍟忛錛屾墍浠ワ紝閭勬槸蹇呴爤鍦?Server.xml 涓紝鍔犱笂 URLEncoding 鐨勫弮鏁歌ō瀹氭墠琛屽摝銆?
Connector 鐨勮ō瀹氱瘎渚嬶細
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15<Connector
debug="0"
acceptCount="100"
connectionTimeout="20000"
disableUploadTimeout="true"
port="80"
redirectPort="8443"
enableLookups="false"
minSpareThreads="25"
maxSpareThreads="75"
maxThreads="150"
maxPostSize="0"
URIEncoding="ISO-8859-1"
>
</Connector>
杞澆鍦板潃錛?BR>http://www.javaworld.com.tw/jute/post/view?bid=9&id=44042&sty=1&tpg=1&age=0
1.涓?/SPAN>杞?/SPAN>錛?/SPAN>
Release Notes: http://tomcat.apache.org/tomcat-5.5-doc/RELEASE-NOTES鎶?/SPAN>jakarta-tomcat-5.5.x.zip
鍜?/SPAN>jakarta-tomcat-5.5.x-compat.zip
鍜?/SPAN>jakarta-tomcat-5.5.x-admin.zip
(Tomcat 榛?/SPAN>璁?/SPAN>鏄病鏈夊唴緗?/SPAN>admin妯?/SPAN>鍧?/SPAN>浜?/SPAN>
Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it. )
閮借В鍘?/SPAN>鍒板悓涓涓洰褰?/SPAN>涓嬮潰銆傛瘮濡傦細D:\jakarta-tomcat-5.5.x\
(濡傛灉浣跨敤jdk1.4錛屾墠闇瑕?/SPAN>compat.zip鐢?/SPAN>jdk1.5灝卞彲浠ュ厤浜?/SPAN>榪?/SPAN>涓?/SPAN>)
2.淇敼jakarta-tomcat-5.5.x\conf\tomcat-users.xml.
娣誨姞綆$悊鍛樿處鍙?/SPAN>lizongbo錛屽瘑鐮佷負lizongbopass.
鏂?/SPAN>xml濡備笅錛?/SPAN>
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="lizongbo" password="lizongbopass" roles="admin,manager"/>
</tomcat-users>
3.淇敼jakarta-tomcat-5.5.x\conf\server.xml鏉ヨВ鍐?/SPAN>緙栫爜闂銆?SPAN lang=EN-US>
(緇?/SPAN>Connector 娣誨姞URIEncoding鍙傛暟
鍙傝?/SPAN> http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx)
(鍙互璁?/SPAN>緗垚GB18030)
<Connector port="8080"
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"/>
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="GBK"/>
4.鍚敤鏀寔gzip鍘嬬緝.
(http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&i=81169)
娣誨姞涓嬪垪灞炴?/SPAN>
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
5.璁?/SPAN>緗櫄鎷?/SPAN>涓繪満銆?/SPAN>
鍦?/SPAN>jakarta-tomcat-5.5.x\涓嬪緩绔嬫枃浠?/SPAN>澶?/SPAN>vhost\www.mydomain.com銆?/SPAN>
鐒跺悗淇敼jakarta-tomcat-5.5.x\conf\server.xml
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="vhost/www.mydomain.com" name="www.mydomain.com">
</Host>
<Host appBase="webapps" name="localhost">
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
6.娣誨姞鏁版嵁搴撻┍鍔?/SPAN>,鏇存柊mail.jar鍜?/SPAN>actiovation.jar
澶?/SPAN>鍒?/SPAN>mysql-connector-java-3.0.16-ga-bin.jar,pg74.215.jdbc3.jar鍒?/SPAN> jakarta-tomcat-5.5.x\common\lib\
榪?/SPAN>鏈?/SPAN>javamail 1.3.2鐨?/SPAN>mail.jar錛?/SPAN>jaf-1_0_2鐨?/SPAN> activation.jar
msSQl 2000 JDBC sp3錛?/SPAN>msbase.jar,msutil,jar,mssqlserver.jar
7.閰嶇疆SSL
鍙傝?/SPAN> 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
杈?/SPAN>鍏?/SPAN>keystore瀵?/SPAN>鐮?/SPAN>錛?/SPAN> lizongbossl
鎮ㄧ殑鍚嶅瓧涓庡姘忔槸浠涔?/SPAN>錛?/SPAN>
[tomcat5.5.x]錛?/SPAN> tomcat5.5.x
鎮ㄧ殑緇勭粐鍗?/SPAN>浣嶅悕縐版槸浠涔?/SPAN>錛?/SPAN>
[jakarta]錛?/SPAN> jakarta
鎮ㄧ殑緇勭粐鍚嶇О鏄粈涔?/SPAN>錛?/SPAN>
[apache]錛?/SPAN> apache
鎮ㄦ墍鍦ㄧ殑鍩庡競鎴栧尯鍩熷悕縐版槸浠涔?/SPAN>錛?/SPAN>
[hzcity]錛?/SPAN> hzcity
鎮ㄦ墍鍦ㄧ殑宸炴垨鐪佷喚鍚嶇О鏄粈涔?/SPAN>錛?/SPAN>
[gdp]錛?/SPAN> gdp
璇ュ崟浣嶇殑涓ゅ瓧姣嶅浗瀹朵唬鐮?/SPAN>鏄粈涔?/SPAN>
[CN]錛?/SPAN> CN
CN=tomcat5.5.x, OU=jakarta, O=apache, L=hzcity, ST=gdp, C=CN 姝g‘鍚?/SPAN>錛?/SPAN>
[鍚?/SPAN>]錛?/SPAN> y
杈?/SPAN>鍏?/SPAN><tomcat>鐨勪富瀵?/SPAN>鐮?/SPAN>
錛堝鏋滃拰 keystore 瀵?/SPAN>鐮?/SPAN>鐩稿悓錛屾寜鍥?/SPAN>杞?/SPAN>錛夛細
(蹇?/SPAN>欏?/SPAN>瀵?/SPAN>鐮?/SPAN>涓鑷達紝鍥犳鐩存帴鍥?/SPAN>杞?/SPAN>)
鐒跺悗鍐嶆妸userhome(渚嬪錛?/SPAN>C:\Documents and Settings\lizongbo\)涓嬬殑.keystore澶?/SPAN>鍒跺埌
tomcat鐨?/SPAN>conf\鐩?/SPAN>褰?/SPAN>涓嬨?/SPAN>
(渚嬪錛?/SPAN>D:\jakarta-tomcat-5.5.x\conf\.keystore )
閰嶇疆jakarta-tomcat-5.5.x\conf\server.xml
鍔犱笂
<Connector port="8443"
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"> <!--涓庡厛鍓?/SPAN>璁?/SPAN>緗殑瀵?/SPAN>鐮?/SPAN>涓鑷?/SPAN>-->
</Connector>
8.紱佹鏂囦歡鐩?/SPAN>褰?/SPAN>鍒楄〃錛?/SPAN>
淇敼jakarta-tomcat-5.5.x\conf\web.xml錛屾妸listing璁?/SPAN>緗?/SPAN>涓?/SPAN>false
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
9.鎸囧畾浜嗚嚜宸辯殑javaEncoding
(鍙傝?/SPAN> http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html )
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>javaEncoding</param-name>
<param-value>GB18030</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
10.娣誨姞rar,iso絳夌殑mime-type鏄犲皠
閬垮厤鍦?/SPAN>嫻忚鍣ㄩ噷鐩存帴鎵?/SPAN>寮銆?/SPAN>
<mime-mapping>
<extension>mht</extension>
<mime-type>text/x-mht</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rar</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>iso</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ape</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>rmvb</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>
10.1瀵筯tml闈欐侀〉闈㈣緗紪鐮?BR> <!-- 淇敼涓嬮潰涓よ浠ユ敮鎸侀潤鎬佽秴鏂囨湰鐨勮嚜鍔ㄧ紪鐮?-->
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html;charset=gb2312</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html;charset=gb2312</mime-type>
</mime-mapping>
</web-app>
11.娣誨姞welcome-file-list錛屽茍璋?/SPAN>鏁?/SPAN>欏?/SPAN>搴忋?/SPAN>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
public static void main(String[] args) {
// Use weblogic test JNDI
// project include BeaHOME\wlserver6.1\lib\weblogic.jar
String bindingkey = "UserAccount";
Context initialContext = null;
try {
// 1 Create a Properties object and set properties appropriately
Properties props = new Properties();
// Take a look at BeaHOME\wlserver6.1\samples\examples\jndi
// 1.1
props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
// 1.2
props.put(Context.PROVIDER_URL, "t3://localhost:7001");
// 2 Create the initial context from the properties we just created
initialContext = new InitialContext(props);
HashMap lst = new HashMap();
lst.put("enterprise_code", "600000");
lst.put("username", "S02888");
lst.put("password", "sysmex");
// Sometimes bind twice will cause NamingException
//initialContext.unbind(bindingkey);
try {
// binding is copy obj's value to server
initialContext.bind(bindingkey, lst);
} catch (NameAlreadyBoundException e) {
initialContext.rebind(bindingkey, lst);
}
// Look up the object. copy obj's value from server
Object obj = initialContext.lookup(bindingkey);
if (bindingkey.equals("")) {
System.out.println("Looked up the initial context");
} else {
System.out.println(bindingkey + " is bound to: " + obj);
}
} catch (NamingException e) {
System.out.println("NamingException msg = " + e.getMessage());
} finally {
if (initialContext != null) {
try {
initialContext.close();
} catch (NamingException e) {
System.out.println("Failed to close context due to: " + e);
}
}
}
}
鐢ˋCLs闄愬埗JNDI璁塊棶
緇橨NDI鐨勮闂姞鍏ユ潈闄愰檺鍒?
1: 鍦?http://localhost:7001/console/ 涓緗?BR> Security--->ACLs Create a new ACL...
Name=weblogic.jndi.myapp // 榪欎釜myapp灝辨槸瑕侀檺鍒剁殑JNDI璺緞.
Permissions=lookup (first time)
Permissions=modify (secend time)
User=user1
if there is a error system has not "modify" permission
please add one line in filerealm.properties
acl.modify.weblogic.admin=Administrators
2: 浠g爜涓闂甁NDI鏄杈撳叆鐢ㄦ埛鍚?瀵嗙爜
static final String JNDI_PATH = "myapp";
public void bindUserData(
String sessid,
String enterpriseCode,
String userId,
String password) {
// Use weblogic test JNDI
// project include BeaHOME\wlserver6.1\lib\weblogic.jar
String bindingkey = sessid;
Context initialContext = null;
try {
// 1 Create a Properties object and set properties appropriately
Properties props = new Properties();
// Take a look at BeaHOME\wlserver6.1\samples\examples\jndi
props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL, "t3://localhost:7001");
// 銉︺兗銈躲亰銈堛伋銉戙偣銉兗銉夈倰 T3User 銇儜銉冦偙銉箋偢鍖栥仐銇︺?BR> // 銉戙偣銉兗銉夈倰紕哄疅銇殫鍙峰寲銇欍倠
props.put(Context.SECURITY_CREDENTIALS, new T3User("user1", "psw1"));
// 2 Create the initial context from the properties we just created
initialContext = new InitialContext(props);
HashMap lst = new HashMap();
//lst.put("enterprise_code", "600000");
//lst.put("username", "S02888");
//lst.put("password", "sysmex");
lst.put("enterprise_code", enterpriseCode);
lst.put("username", userId);
lst.put("password", password);
try {
initialContext.createSubcontext(JNDI_PATH);
System.out.println("Subcontext 'myapp' created");
} catch (NameAlreadyBoundException e) {
// 銈點儢銈熾兂銉嗐偔銈廣儓銇屻仚銇с伀瀛樺湪銇椼仸銇勩倠銆?BR> // 鍚嶅墠銇屽悓銇樸偑銉栥偢銈с偗銉堛伀銇欍仹銇儛銈ゃ兂銉夈仌銈屻仸銇勩倠鍫村悎銆?BR> // WebLogic 銇偝銉熾儐銈偣銉堛伄瀹熻銇с併亾銇緥澶栥伅閫佸嚭銇曘倢銇亜銆?BR> System.out.println("Subcontext 'myapp' already exists;" + " continuing with existing subcontext");
}
initialContext.unbind(JNDI_PATH + "." + bindingkey);
// bind is copy obj's value to server
initialContext.bind(JNDI_PATH + "." + bindingkey, lst);
// Look up the object. copy obj's value from server
Object obj = initialContext.lookup(JNDI_PATH + "." + bindingkey);
if (bindingkey.equals("")) {
System.out.println("Looked up the initial context");
} else {
System.out.println(
JNDI_PATH + "." + bindingkey + " is bound to: " + obj);
}
} catch (NamingException e) {
System.out.println("NamingException msg = " + e.getMessage());
} finally {
if (initialContext != null) {
try {
initialContext.close();
} catch (NamingException e) {
System.out.println("Failed to close context due to: " + e);
}
}
}
}
// 琛ュ厖:閬嶅巻鎵鏈夊厓绱?BR>NamingEnumeration ne = initialContext.list("."); // 鐢ㄥ彞鍙瘋〃紺烘牴鐩綍
while (ne.hasMoreElements()){
System.out.println(ne.next());
}