顯示具有 web 標籤的文章。 顯示所有文章
顯示具有 web 標籤的文章。 顯示所有文章

2014年1月6日 星期一

hostname and domain

hostname 主機名稱 and domain name 領域名稱

Fully Qualified Domain Name, FQDN 兩者組成的完整主機名稱

format: hostname.domain.com

ex: 以區域號碼來區分相同的電話號碼

(02)2600-1234

區碼 (02) => domain name
電話號碼 (26001234) => hostname

=> 26001234.02

ex: www.ksu.edu.tw

domain name     hostname
.tw                    edu               -> .edu.tw tw 下有其他更小網域的主機 ex: com, gov, edu...
.edu.tw             ksu                -> .ksu.edu.tw
.ksu.edu.tw       www              -> www.ksu.edu.tw

hostname: 主機名稱(位置)
domain name: 指定是哪個(區域的) hostname



* Reference
- Difference between host name and domain name

2014年1月2日 星期四

[Web] attribute 命名中包含句點

model.put("aaa.bbb", "xxx");

在 jsp 中用 ${aaa.bbb} 不會顯示任何東西 會被視為 bbb 是 class aaa 中的 attribute

必須要寫成

${requestScope['aaa.bbb']}


* Reference
- Dots in attribute names

2013年9月2日 星期一

[Web] Note

disable
設為 true 欄位值不會被送出




< form:input path= "name" value = "${name}" ${xxx ?  "disabled='disbaled'" : ""}  />




value
沒有 value 不會觸發 setXXX 用 getParameter 會取到 null
value="" 會送空的
value 會送null


url mapping
"/{" + ATTRIBUTE_PACKAGE_NAME + ":.+}"


htmlEscape
true = render(escape?) to html
false = show the text

[Web] enum form value

Error

<form:radiobutton value="enum type object">

post 時發生 mistypematched exception



Solution

<form:radiobutton value="enum.toString">

因為 enum 會被 toString


http param string <-> enum name


2013年1月21日 星期一

[Web] object from request parameters

Error Message

ERROR - [Ljava.lang.String; cannot be cast to java.lang.String
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String


Solution

注意使用的物件 type,Map<String, String[]> or Map<String, String>。


Map<String, String[]> requestParameters = request.getParameterMap();
Map<String, String> parameters = new Map<String, String>();
for(String key: requestParameters.keySet())  {
    parameters.put(key, requestParameters.get(key)[0]);
}

2012年12月1日 星期六

[Web] http request parameter

In http request
  • 沒有該 element: get null.
  • 有該 element 但沒有帶 value: get ""

2012年6月22日 星期五

[Web] Brief notes


  • slf4j
    • 在 jar 檔時就 binding,比較好切換。
  • framework
    • 提供 pattern 的模組
  • Spring framework
    • 本身是個大 factory,將工作交給底下的 factory...
  • Struts2
    • #attribute 作用約是 ${attribute}
  • iBatis
    • $var$
      • paraClass 中的 attribute
    • #fieldName:fieldType#
      • Table field
  • HTML
    • 由上而下 compiler,結果會是 DOM tree 結構。
    • DTD
      • 描述 HTML syntax
    • <meta>
      • 提供和 browser or search engine 相關的訊息。
      • ex: 描述文檔的內容。

2012年2月16日 星期四

[Tiles] Cascade



    

    



[Web] 新增資料處理

分頁會共用 session (Ref: [Web] session ID with browser)

所以顯示頁面時 把 Object(ex: Token) 放入 session 且將 Object 的 key 傳給頁面

model.put(ATTRIBUTE_TOKEN, token.getKey);
session.setAttribute(token.getKey(), token);

頁面 submit 時將 key 帶在路徑上

然後便能由 key 取出 session 中相對應的 token

藉此區別不同 tab 間的新增資料

2011年11月7日 星期一

[Web] session ID with browser

若要分開 session ID
  • 最快的處理方式
    • 啟動兩個不同的瀏覽器。
  • 如果要同個瀏覽器,則
    • IE 可以建立捷徑 "C:\Program Files\Internet Explorer\iexplore.exe" -nomerge
    • FF 可以 "C:\Program Files\Mozilla Firefox\firefox.exe" -p -no-remote


下面把幾個常用瀏覽器的 session 管理方式列一下:
  • IE
    • IE6
      • session 不共享。
    • IE7
      • 不同 window,session 不共享。
      • 同一個 window 不同 tab ,session 共享。
    • IE8
      • 不同 window,session 共享。
      • 同一個 window 不同 tab,session 共享。
  • Firefox
    • session 共享。
  • Chrome
    • session共享。

2011年9月23日 星期五

[IE] focus

Error Message

在 IE6 和 IE7 上

若想要同時 focus 在頁面上和 alert 訊息

會因為先 alert 出訊息 而當使用者關掉 alert 再回到頁面上時

focus 效果已經消失 使用者也因此不會看到



Solution

利用 setTimeout( ) 來延遲 focus 事件 好讓使用者來得及看見

2011年9月18日 星期日

[WEB] Tile, JSTL, JS syntax in HTML





${status.count}


 colspan="2">



* Tile 的 attribute 在 HTML 中可透過 getAttribute 取得,ex:

<tiles:insertAttribute name="title" />





* 視 js 為 .txt







2011年9月17日 星期六

[Velocity] Brief Definition

* Velocity Template Language (VTL)
  • VTL uses references to embed dynamic content in a web site, and a variable is one type of reference.
  • Variables are one type of reference that can refer to something defined in the Java code, or it can get its value from a VTL statement in the web page itself.

Syntax:

##comment


#* comment *#


#directive
    
#end





$variable


#if ( expression)
#end


#foreach($item in $list)
    $item 
#end 


* When an online visitor requests your web page, the Velocity Templating Engine will search through your web page to find all # characters, then determine which mark the beginning of VTL statements, and which of the #characters that have nothing to do with VTL.

* #if
(i) $foo is a boolean (true/false) which has a true value, or
(ii) the value is not null. Remember that the Velocity context only contains Objects, so when we say 'boolean', it will be represented as a Boolean (the class).


* Reference
- Apache User Guide - Contents
- apache velocity介绍及资料: 可下載文件。
- Apache Velocity实现模板化的最简实例 - 玉米疯收 - 博客园: 圖解

2011年9月14日 星期三

[Weblogic] Domain and Managed

weblogic 分為兩部份

  1. Domain
  2. Managed

然後 Domain 會管理 Managed

每個 Managed 有一個 JVM

若一個 Domain 中有的三個 Managed

則表示管理四個 (再加 Admin)

2011年9月3日 星期六

[Web] CDATA

* 原本要在 xml 中使用特殊字元時,則必須寫成 &lt;、&gt;、、等,否則 xml 分析會出錯。


* CDATA 區段提供了一種通知剖析器的方法,說明 CDATA 區段所包含的字元沒有標記。 寫法如下:


<![CDATA[  >   ]]>


* 也就是說在 CDATA 中的字元不會被解析。




* Reference
- CDATA 區段 - XML 標準

2011年8月27日 星期六

The Java Naming and Directory Interface (JNDI)

(from JWorld@TW Java論壇 - JNDI觀念)


* The Java Naming and Directory Interface (JNDI) is a Java API for a directory service that allows Java software clients to discover and look up data and objects via a name.

* Like all Java APIs that interface with host systems, JNDI is independent of the underlying implementation.

* Additionally, it specifies a service provider interface (SPI) that allows directory service implementations to be plugged into the framework. It may make use of a server, a flat file, or a database; the choice is up to the vendor.

* 在 J2EE 中,JNDI 是把 J2EE 應用程式何在一起黏著劑,將資源取名字,提供命名服務,以可以根據名字來找到資源。假設要連的對象是書,而JNDI是圖書管理員,把書碼告訴管理員便會找到相對應的書

* JNDI is a connection pool,工作效率比直接連接好。

* JNDI 是一種樹狀的檔案系統結構,每個節點都可以儲存任何物件,客戶端程式可以透過 JNDI path 來查詢所儲存的物件或是更新物件的值,延伸到 client-server 的觀念,就好比存取網路磁碟的檔案一樣。

* 只不過 JNDI 的路徑的定義跟檔案系統的定義不太相同,儲存的內容也不限是檔案而是廣義的物件。


* Reference
- 请问个位JNDI到底是什么意思呀,始终没有理解清楚 - Java / Java SE
- Java Naming and Directory Interface - Wikipedia, the free encyclopedia
- JWorld@TW Java論壇 - JNDI觀念

2011年8月13日 星期六

[Web] RESTful brief definition

以 URL 定位資源,根據 HTTP 內容指示操作動作與回應訊息,其概念結合了 HTTP 與 URL 兩種協定,以及如何運用於網路軟體架構設計。

一個符合上述實作方式的網路服務,就稱之為 RESTful web service。

有些文章則更進一步,將 ATOM 協定也加了進來,主要是看上 ATOM 格式的特點,將之運用於資源內容的更新工作。

有些 RESTful 文章還會強調要透過 HTTP Authorization 限制使用者存取資源的權限,而不是用表單加 Cookie。


* Reference
- 石頭閒語:RESTful 介面實作示範 - 樂多日誌

[AndroidLayout] WebView Performance

webView 加載頁面的順序:

  1. html
  2. css, js, static resources in this html unless have been loaded in cache
  3. render css(大約幾十毫秒) and execute js(如果使用了 jQuery 則需要 5-6 秒,這段時間內若無設背景,則會顯示白色)



* Reference
- WebView执行效率部分 - Envisage123 - ITeye技术网站

2011年8月6日 星期六

[Format] JSON

* Definition
  • JSON: Javascript Object Notation。
  • 輕量級的資料交換語言,以文字為基礎,且易於讓人閱讀。
  • 儘管JSON是在Javascript的一個子集,但JSON是獨立於語言的文字格式,並且採用了類似於C語言家族的一些習慣。
  • 幾乎所有與網頁開發相關的語言都有JSON函式庫。
  • JSON與XML最大的不同在於XML是一個完整的標記語言,而JSON不是。
    • 這使的XML在程式判讀上需要比較多的功夫。主要的原因在於XML的設計理念與JSON不同。
    • XML
      • Easy extensible.
        • XML利用標記語言的特性提供了絕佳的延展性(如XPath),在資料儲存,擴充功能及高階檢索方面具備對JSON的優勢。
    • JSON
      • More faster when using.
        • JSON則由於比XML更加小巧,以及瀏覽器的內建快速解析支援,使得其更適用於網路資料傳輸領域。
      • More Security
        • 由於Javascript採用了稱為「沙盒」的機制,這種機制限制Javascript引擎僅能引入同一個站點的代碼,因而某種程度上提高了安全性。

* Java API
  • key is case sensitive.
  • A get method returns a value if one can be found, and throws an exception if one cannot be found.
  • The generic get() and opt() methods return an object, which you can cast or query for type. 
    • There are also typed get and opt methods that do type checking and type coercion for you. 
    • The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such as null.
  • Strings do not need to be quoted at all if... 
    • they do not begin with a quote or single quote, 
    • they do not contain leading or trailing spaces, 
    • they do not contain any of these characters: { } [ ] / \ : , = ; # 
    • they do not look like numbers and if they are not the reserved words true, false, or null.

* Reference
- 介绍 JSON : Have JSON format figures.
- wiki JSON : Have JSON examples.
- RFC 4627
- JSON : Explain with Javascript.
- JSON 速寫 : Javascript syntax example.
- Class JSONObject **
- android开发中文文档之基于JSON数据交换应用