Showing posts with label techDoc. Show all posts
Showing posts with label techDoc. Show all posts

Friday, October 26, 2007

web.xml的內容

Web.xml是一在web application deploy的時候必要的file, 它是被放置於/WEB-INF/之下的. 由於它是個xml file, 所以檔案內的大小寫有別. 另外, 所有element排放的順序是規定的.

1. Head: 檔案的開頭必定為xml head, 大多為:
<?xml version="1.0" encoding="UTF-8" ?>
2. DOCTYPE: 告訴server servlet的版本(是2.2或是2.3)
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" http://java.sun.com/dtd/web-app_2_3.dtd&gt>
3. Root: 必定為<web-app> 且一定為小寫. 如:
<web-app>
<!-- Other elements go here. All are optional. -->
</web-app>
4. Elements: 順序必定為以下順序:
  • icon
  • display-name
  • description
  • distributable
  • context-param
  • filter
  • filter-mapping
  • listener
  • servlet
  • servlet-mapping
  • session-config
  • mine-mapping
  • welcome-file-list
  • error-page
  • taglib
  • resource-env-ref
  • resource-ref
  • security-constraint
  • login-config
  • security-role
  • env-entry
  • ejb-ref
  • ejb-local-ref

詳細內容可以參考dtd的定義, 下面指列出一些我常用的elements以及一些注意事項.

1. servlet: 常用servlet-name以及servlet-class這兩個subelements. servlet-name一定要先出現, 才能出現servlet-class. 它的影響有兩個a). initialization parameters, custom URL patterns, and other customizations refer to the servlet by the registered name, not by the class name. b). the name can be used in the URL instead of the class name. 也就是我可以用http://host/webAppPrefix/servlet/xxx代替http://host/webAppPrefix/servlet/package.yyyServlet來連結, 其中xxx是設定的servlet-name, package.yyyServlet是servlet的class. 另外, 若是此servlet為一個jsp檔案的時候, 請改用jsp-file這個tag去代替servlet-class, 因為我們無法得知jsp被編譯之後的class名稱為何. 而一個container當中可以有很多個servlet, 所以在web.xml當中也可以同時定義很多個servlet.

2. servlet-mapping: 用於客制化URL, 一般結構為:

<servlet-mapping> <servlet-name>name</servlet-name> <url-pattern>url</url-pattern> </servlet-mapping>
其中name就是在servlet中所定義的servlet-name, 而url則為一個pattern,大致有下面幾種形式
a).路徑映射: 以/開頭或是以/*結尾
b).擴展映射: 以前綴*.開頭
c).default servlet映射: 使用/
d).詳細映射: 如ab/tt/cc.action
因此定義/*.action會出錯的原因,是由於同時有路徑mapping也有擴展的mapping, 所以container無法判斷

3. 使用servlet的initialization parameters. 一般型態為類似於下面的格式:

<servlet>
<servlet-name>InitTest</servlet-name>
<servlet-class>myPackage.InitServlet</servlet-class>
<init-param>
<param-name>param1</param-name>
<param-value>Value 1</param-value>
</init-param>
</servlet>
Initialization parameters are only available whenservlets are accessed by means of their registered names or throughcustom URL patterns associated with their registered names. Initialization parameters are not available in servlets that are accessedby their default URL. 而自己撰寫servlet的init()時可以利用getServletConfig().getInitParameter("...") 來取得type為String的parameter.

4.context-param可以設定提供給整個system, 裡面包含的subelement為context-name以及context-value.

5.若要將servlet在system啟動時就load進來, 可以使用load-on-starup這個tag

6.Welcome page的設定是透過welcome-file-list這個element來達到, 而放置於當中的welcome-file是有順序可言的, 若是第一個找不到, 則會找第二個, 以此類推, 直到沒有則使用server所設定的.

7.

Friday, March 23, 2007

如何使用 Win32 API 存取 RS232

http://www.csie.ntu.edu.tw/~b88032/expr/AcceRS232.htm

This is a reference link to tell me how to use Win32 API to access RS232.
A clearly and easy one.


Thursday, January 18, 2007

LED燈接法

LED要串一個電阻
假設LED的規格是x V, 工作店最大事 y mA
則串接的電阻的電阻值為 (電源電壓 - x)/z, 其中z <= y
一般來說z=0.01
因此紅色1.8V的LED要串大概330歐姆的電阻

電阻的串法
LED長腳接五伏電壓
短腳接電阻
電阻的另一個腳接地

圖晚點補

Friday, October 27, 2006

[ProComp] Acquiring Live Data

The following steps outline a minimal set of functions required to acquire live data from a connected encoder.

To acquire live data:
1. Initialize the COM environment by calling CoInitialize or CoInitializeEx.
    • HRESULT hr = CoInitializeEx(NULL, COINIT_ APARTMENTHEREADED);
    • CheckHRESULT(hr);
    • SUCCEEDED(hr);
2. Create an instance of a TTLLiveCtrl object and query for its ITTLLive or ITTLLive2 interface.
    • HRESULT hr = g_TTLLive.CreateInstance(CLSID_TTLLive);
    • CheckHRESULT(hr);
    • SUCCEEDED(hr);
3. Detect and open encoder connection(s) using the OpenConnection or OpenConnections method.
    • g_TTLLive->OpenConnections(TTLAPI_OCCMD_AUTODETECT, 1000, NULL, NULL);
4. Close any unwanted connections using CloseConnection.
    • g_TTLLive->CloseConnections();
5. Optionally define the encoder enumeration order by calling AssignEncoderHND.
    • not sure yet
6. Create logical channels corresponding to all encoder physical channels using AutoSetupChannels.
7. Synchronously start all channels using StartChannels.
8. Retrieve data periodically using ReadChannelData or ReadChannelDataVT.
9. When finished, close all connections using CloseConnections.
10. Release queried ITTLLive or ITTLLive2 interface.
11. Match the previous call to CoInitialize or CoInitializeEx with a call to CoUninitialize

==
basic from the dacument of ProComp.

Thursday, October 05, 2006

5 model of emotion

I read the first part of the book ``What is an Emotion''. It mentions five differnt view and research area in the emotion due to the personal phylosophy. They are
  • Considering emotions and metal phenomena are different. (distinguish their differnce)
  • Grouping emtions into generic type. (classification)
  • Using the physiological changes to detect emotional changes. (Dominant now, using the physiology)
  • Role of emotion. (Social effect of emotion, person to person effect, etc. )
  • Analyzing emotion into its components or aspects.
Because of the differnt phylosophys, there are diffent theories, such as sensation theories, physiological theories, behavioral theories, evaluative theories, and cognitive theories.

Monday, June 05, 2006

ANOVA

a test to measure the difference between the means of two or more groups.