內容 |
|
經過測試之後發現,svnaccess中的[/]是給Trac看的,其他部分[repos-name:/]才是給Apache看的,如果您將[/]底下的 * = r刪除,則您需要將其他可以讀取或寫入的使用者明確地加到這個section來,例如:
[/]
admin = rw
user1 = rw
user2 = rw
否則在Trac登入後按下 Browse Source時會出現 Insufficient permissions to access /的錯誤。
如果要管控http://localhost/svn/project1時需要輸入帳號密碼,則可以修改/etc/httpd/conf.d/subversion.conf中的設定
<Location /svn>
DAV svn
SVNParentPath /home/andowson/repos
#<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /home/andowson/projects/.htpasswd
AuthzSVNAccessFile /home/andowson/projects/svnaccess
Require valid-user
#</LimitExcept>
</Location>
將原來的<LimitExcept>註解掉或刪除掉,再重新啟動Apache即可
|
 |
|
wu_net2008您好,老實說,沒看到原始碼實在不知道怎麼判定是不是您的程式的問題。不過簡單來看,如果您將User物件存到HttpSession物件的attribute去,則這個HttpSession中的User物件應該就會在web.xml對Session所定義的timeout時間消失,在您的狀況就是20分鐘。User物件消失後就變成未登入狀態,所以這樣算正常現象。
|
 |
|
這個很簡單啊,用FTPClient類別的listFiles()來取得現行工作目錄的檔案清單(FTPFile[]),然後跑一個for迴圈,將每個元素拿出來判斷是否是一個目錄(isDirectory())且名稱(getName())等於目錄A,如果存在就終止迴圈,並將變數dirExist設定為true。
if (ftp.login(username, password)) {
boolean dirExist = false;
String dirA = "upload";
FTPFile[] files = ftp.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory() && files[i].getName().equals(dirA)) {
dirExist = true;
break;
}
}
out.println("directory " + dirA + " exists? " + dirExist);
if (!dirExist) {
ftp.makeDirectory(dirA);
}
}
|
 |
|
目前得到的結論是:
SCJP 1.4版時,選中文是可以切換回英文的。
SCJP 5.0版起,選中文是無法切換回英文的。
所以要考SCJP 6的人報名時就要選好英文版,再搭配猛虎出閘的180題英文試題準備,過關的機率就很大囉!
另外我發現考試當時有些中文題目和猛虎的英文題目稍微有點小變化(算類似題),由於考試前一天把題目都做過一遍,所以印象很深刻,看了幾行答案就直接寫下去了,後來再檢查時有發現差異,考英文版的話應該就可以更容易區分出來吧!
至於要不要補習,應該是因人而異吧,對於像我這種已經用Java開發程式多年或資訊本科系的人,複習式的補習就還OK,可能就是一些常考觀念的釐清,大概三~四天這種,包含提供練習題及練習題講解等。不過,自己認真K書應該是不二法門。
至於非資訊本科系的人,如果沒有寫程式的基礎,補習應該是條捷徑,可以上各大教育訓練中心的SCJP認證輔導課程,相信效果應該也是不錯。不過,多寫些程式是一定要的。
|
 |
|
viva wrote:
在請教一下...(我好像問題好多,不知道會不會造成你困擾)
我已經寫好我自己要使用的FTP程式...
但....如果在FTP設定伺服器種類設為FTPES-透過外顯式TLS/SSL的FTP
那我的FTP程式還連的上嗎?
有問題互相討論是OK的,不過希望能提供較多的資訊,例如完整或部分的程式碼,這樣子別人對於您的問題的內容會比較清楚。
目前支援 FTPS的Java FTP Library大多是commercial component,如 edtFTPj/Pro。所以您的程式需要換掉Library及修改部分程式碼才能連上。
我找到了一個FTPES的範例程式,網址如下:
http://www.example-code.com/java/ftp_AuthSSL.asp
您可以參考,用到的元件下載網址如下:
http://www.chilkatsoft.com/download/ChilkatJava.zip
|
 |
|
viva wrote:不好意思,在請教一下
ftp.setDefaultPort(21);
這語法的用意是什麼?為何會設21與13?
若不加這行,也OK嗎?
因為FTP通訊協定預設的通訊埠是21,而org.apache.commons.net.ftp.FTP.DEFAULT_PORT的值即為21,所以如果您要連的FTP Server沒有改過port號的話,不用加這一行也OK。
另外,我的範例程式中應該是沒加這一行,也沒看到什麼13的數字,所以我無法回答「為何會設21與13?」
|
 |
|
SQL Server 2005 Express的SQL Server Management Studio Express沒有提供匯入/匯出精靈,只有在花錢買的版本才有提供,若要從Excel匯入資料只能從SQL查詢視窗使用SQL指令匯入,但要使用SQL指令匯入需要先開啟OPENROWSET才能執行匯入功能。
依序操作如下:
Microsoft SQL Server 2005 > 組態工具 > SQL Server 2005 介面組態 > 功能的介面區組態 > 勾選「啟用OPENROWSET和OPENDATASOURCE支援」
將要匯入的Excel檔就定位,例如放在D:\testdata\zipcode.xls,檢查一下,第一行是欄位名稱,第二行起是資料的部分,然後工作表名稱可以維持原本的Sheet1或是自己重新命名(記得下面的Sheet1$要配合修改)
接著就可以執行
SELECT * INTO zone FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testdata\zipcode.xls', [Sheet1$])
http://sunrise-msn.spaces.live.com/blog/cns!487A9984929026B7!392.entry
http://support.microsoft.com/kb/321686
http://forums.microsoft.com/Technet-CHT/ShowPost.aspx?PostID=3697780&SiteID=23
|
 |
|
|
 |
|
viva wrote:不好意思請問一下
ftptest.jsp裡有這一行 ftp.setDefaultTimeout(30000);
設定這時間是什麼意思?
原來的程式碼上寫了:
// We want to timeout if a response takes longer than 30 seconds
ftp.setDefaultTimeout(30000);
因為setDefaultTimeout(int timeout)裡面timeout的單位是milliseconds(千分之一秒),故我們要乘上1000,就變成30000。
至於為何要設定Timeout,是因為在建立TCP的socket連線時,需要等候連線的對方回應ACK,以確認對方還活著,而這個等候的時間就是Timeout的時間,超過這個時間,我們就認為對方掛了,這個connection就無法成功建立。
|
 |
|
這個週末花了兩天終於把現有的OLAT由5.2.3升級至6.0.0, 步驟如下:
cd ~/download
mv olat3 olat-5.2.3
wget http://www.olat.org/downloads/stable/OLAT-6.0.0.zip
unzip OLAT-6.0.0.zip
mv OLAT-6.0.0-PUBLIC-* olat3
cd olat3
sed -e "s/\/usr\/local\/opt\/olat\/olat3/\/home\/andowson\/download\/olat3/g" \
-e "s/\/usr\/local\/opt\/olat\/olatdata/\/home\/andowson\/www\/data\/olatdata/g" \
-e "1,$$s/myolat/andowson/g" \
-e "s/smtp.host=smtp.andowson.com/smtp.host=mail.andowson.com/" \
-e "s/\/usr\/local\/opt\/tomcat/\/var\/tomcat5/g" \
-e "1,$$s/net.sf.hibernate/org.hibernate/g" \
-e "48c\server.modjk.enabled=true" \
-e "95,117d" \
-e "1,$$s/#db/db/g" \
-e "s/instantMessaging.enable=false/instantMessaging.enable=true/" \
-e "s/instantMessaging.server.name=jabber.andowson.com/instantMessaging.server.name=www.andowson.com/" \
-e "s/instantMessaging.generateTestUsers=false/instantMessaging.generateTestUsers=true/" \
-e "s/instantMessaging.db.name=wildfire/instantMessaging.db.name=openfire/" \
-e "s/instantMessaging.db.user=wildfire/instantMessaging.db.user=olat/" \
-e "s/instantMessaging.db.pass=wildfire/instantMessaging.db.pass=olat/" build.properties.default > build.properties
ant install
ant jsmath
sudo /etc/init.d/tomcat stop
mv ~/www/olat /tmp/olat-5.2.3
cp -rf ~/download/olat3/webapp ~/www/olat
cp -rf ~/download/olat3/htdocs/* ~/www/olat
sed -i -e "13c\ <\!-- default session timeout -->" ~/www/olat/WEB-INF/web.xml
rm -rf ~/www/olat/WEB-INF/src
rm -rf ~/www/olat/WEB-INF/patchesSrc
rm -rf ~/www/olat/WEB-INF/test
cp /tmp/olat-5.2.3/WEB-INF/classes/hibernate.properties ~/www/olat/WEB-INF/classes/.
chgrp -R tomcat ~/www/olat
chgrp -R tomcat ~/www/data/olatdata
chmod 775 ~/www/olat/static
sudo -u postgres pg_dump olat > /tmp/olat.bak
sudo psql -U olat olat -f /home/andowson/download/olat3/database/postgresql/alter_5_2_x_to_6_0_0.sql
sudo /etc/init.d/tomcat start
要注意的地方是原始碼內附的PostgreSQL升級SQL script有問題,字串應該用單引號來括起來,而不是用雙引號,另外有些欄位名稱也不對,必須調整後才能正常執行。好在我有先執行資料庫備份,再執行那條upgrade的SQL,不然這個SQL script只能執行一次,並且會把o_user裡面的一些欄位drop掉(這樣子你連執行第二次的機會都沒有了)。所以記住:要做任何系統升級之前,備份!備份!備份!
以下是我修改後的alter_5_2_x_to_6_0_0.sql:
--
-- new talbe to store the users properties
create table o_userproperty (
fk_user_id int8 not null,
propname varchar(255) not null,
propvalue varchar(255),
primary key (fk_user_id, propname)
);
create index propvalue_idx on o_userproperty (propvalue);
alter table o_userproperty add constraint FK4B04D83FD1A80C95 foreign key (fk_user_id) references o_user;
--
-- migrate data from old user table to new userproperty table
-- make sure you get this right the first time, you can not run this twice!
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'firstName', firstname from o_user where firstname IS NOT NULL AND firstname!='';
alter table o_user drop firstname;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'lastName', lastname from o_user where lastname IS NOT NULL AND lastname!='';
alter table o_user drop lastname;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'email', email from o_user where email IS NOT NULL AND email!='';
alter table o_user drop email;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'birthDay', birthday from o_user where birthday IS NOT NULL;
alter table o_user drop birthday;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'gender', gender from o_user where gender IS NOT NULL AND gender!='';
alter table o_user drop gender;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telMobile', telmobile from o_user where telmobile IS NOT NULL AND telmobile!='';
alter table o_user drop telmobile;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telOffice', teloffice from o_user where teloffice IS NOT NULL AND teloffice!='';
alter table o_user drop teloffice;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'telPrivate', telprivate from o_user where telprivate IS NOT NULL AND telprivate!='';
alter table o_user drop telprivate;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalUserIdentifier', institutionaluseridentifier from o_user where institutionaluseridentifier IS NOT NULL AND institutionaluseridentifier!='';
alter table o_user drop institutionaluseridentifier;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalName', institutionalname from o_user where institutionalname IS NOT NULL AND institutionalname!='';
alter table o_user drop institutionalname;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'institutionalEmail', institutionalemail from o_user where institutionalemail IS NOT NULL AND institutionalemail!='';
alter table o_user drop institutionalemail;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'street', street from o_user where street IS NOT NULL AND street!='';
alter table o_user drop street;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'extendedAddress', extendedaddress from o_user where extendedaddress IS NOT NULL AND extendedaddress!='';
alter table o_user drop extendedaddress;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'poBox', pobox from o_user where pobox IS NOT NULL AND pobox!='';
alter table o_user drop pobox;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'zipCode', zipcode from o_user where zipcode IS NOT NULL AND zipcode!='';
alter table o_user drop zipcode;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'region', region from o_user where region IS NOT NULL AND region!='';
alter table o_user drop region;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'city', city from o_user where city IS NOT NULL AND city!='';
alter table o_user drop city;
insert into o_userproperty (fk_user_id, propname, propvalue) select user_id, 'country', country from o_user where country IS NOT NULL AND country!='';
alter table o_user drop country;
--
-- end user properties migration
-- new table to store the read messages, migrate the read messages from the o_property to the new table
create table o_readmessage (
id int8 not null,
lastmodified timestamp not null,
creationdate timestamp,
identity_id int8 not null,
forum_id int8 not null,
message_id int8 not null,
primary key (id));
create index identity_forum_idx on o_readmessage(identity_id, forum_id);
insert into o_readmessage (id, lastmodified, creationdate, identity_id, forum_id, message_id) select id, lastmodified, creationdate, identity, resourcetypeid, longvalue from o_property where category='rvst';
delete from o_property where category='rvst';
-- end read messages
-- update fontsize to new relative style
update o_user set fontsize = '110' where fontsize = 'large';
update o_user set fontsize = '100' where fontsize = 'normal';
update o_user set fontsize = '90' where fontsize = 'small';
-- end fontsize update
|
 |
|
Java內建支援ZIP格式檔案的壓縮及解壓縮,透過使用 java.util.zip套件,我們可以用來將網頁上傳的ZIP檔案加以解壓縮再做後續處理。這裡我們可以先將解壓縮的固定步驟寫成一個UnZipBean,後續要解壓縮zip時只要先將檔名及解壓縮的目錄傳進去,再呼叫unzip()函式即可。
程式碼:
UnZipBean.java:
/*
* Copyright (c) 2005, Andowson Chang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of the "Andowson Chang" nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* This file creation date: 2005/01/31 18:33:36
* Reference:
* http://www.wakhok.ac.jp/~tatsuo/sen97/10shuu/UnZip.java.html
*/
package com.andowson;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
public class UnZipBean {
public static final int EOF = -1;
static final int BUFFER = 2048;
private String zipFile;
private String targetDirectory;
private ZipFile zf;
/** Constructor */
public UnZipBean() {
}
public UnZipBean(String zipFile, String targetDirectory) {
this.zipFile = zipFile;
this.targetDirectory = targetDirectory;
}
public void setZipFile(String zipFile) {
this.zipFile = zipFile;
}
public String getZipFile() {
return zipFile;
}
public void setTargetDirectory(String targetDirectory) {
this.targetDirectory = targetDirectory;
}
public String getTargetDirectory() {
return targetDirectory;
}
public boolean unzip() {
boolean done = false;
if (zipFile != null) {
try {
zf = new ZipFile(zipFile);
Enumeration enumeration = zf.entries();
while (enumeration.hasMoreElements()) {
ZipEntry target = (ZipEntry)enumeration.nextElement();
System.out.print(target.getName() + " .");
saveEntry(target);
System.out.println(". unpacked");
}
done = true;
}
catch (FileNotFoundException e){
System.out.println("zipfile not found"+e.getMessage());
}
catch (ZipException e){
System.out.println("zip error..."+e.getMessage());
}
catch (IOException e){
System.out.println("IO error..."+e.getMessage());
}
finally {
try {
zf.close();
} catch (IOException e) {
System.out.println("IO error...Can't close zip file"+e.getMessage());
}
}
}
return done;
}
private void saveEntry(ZipEntry target)
throws ZipException, IOException {
try {
File file = new File(targetDirectory + File.separator + target.getName());
if (target.isDirectory()) {
file.mkdirs();
}
else {
InputStream is = zf.getInputStream(target);
BufferedInputStream bis = new BufferedInputStream(is);
File dir = new File(file.getParent());
dir.mkdirs();
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int c;
byte[] data = new byte[BUFFER];
while((c = bis.read(data, 0, BUFFER)) != EOF) {
bos.write(data, 0, c);
}
bos.flush();
bos.close();
fos.close();
}
}
catch (ZipException e) {
throw e;
}
catch (IOException e) {
throw e;
}
}
}
unziptest.jsp:
<%@ page contentType="text/html; charset=Big5" errorPage="" %>
<%@ page import="com.andowson.UnZipBean" %>
<%
String zipFile = "c:\\temp\\test.zip";
String targetDirectory = application.getRealPath("/tmp");
UnZipBean uzb = new UnZipBean(zipFile, targetDirectory);
boolean succ = uzb.unzip();
if (succ) out.println(uzb.getZipFile() + " UnZipped");
%>
參考資料:
http://java.sun.com/developer/technicalArticles/Programming/compression/
http://www.wakhok.ac.jp/~tatsuo/sen97/10shuu/UnZip.java.html
|
 |
|
url="jdbc:oracle:thin:@(DESCRIPTION=
(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=service_name)))"
參考資料
http://docs.oracle.com/cd/B14117_01/rac.101/b10768/example.htm#RACDP202
|
 |
|
|
 |
|
您可以看一下SystemGlobals.properties裡面的這幾個跟cahce有關的參數:
# ############
# Cache Stuff
# ############
topicsPerPage = 15
postsPerPage = 15
usersPerPage = 30
hot.topic.begin = 20
topic.recent = 50
posts.cache.enabled = false
posts.cache.size = 100
# Caching
topic.cache.enabled = true
security.cache.enabled = true
cache.engine.default = net.jforum.cache.DefaultCacheEngine
cache.engine.jboss = net.jforum.cache.JBossCacheEngine
jboss.cache.properties = ${config.dir}/jboss-cache-cluster.xml
cache.engine.implementation = ${cache.engine.default}
cacheable.objects = net.jforum.repository.BBCodeRepository, \
net.jforum.repository.RankingRepository, \
net.jforum.repository.SmiliesRepository, \
net.jforum.repository.ForumRepository, \
net.jforum.repository.TopicRepository, \
net.jforum.SessionFacade, \
net.jforum.repository.PostRepository, \
net.jforum.util.search.quartz.QuartzSearchIndexerJob, \
net.jforum.repository.Tpl, \
net.jforum.repository.RolesRepository, \
net.jforum.repository.SecurityRepository
cache.dir = cache
|
 |
|
請問您有修改newproject.sh的第7~17行的參數嗎?
我有個建議就是可否請您將Trac整個移掉重裝,然後按照我這篇文章的預設路徑去裝裝看,先排除掉路徑問題,如果裝得起來您可再自行調整路徑重新安裝一次。
|
 |
|
|
|