- 建立並佈署 Session Bean (EJB 3.1)
- 在 Servlet 中使用 Glassfish 上的 Session Bean
- 在 JSP 中使用 Glassfish 上的 Session Bean
- 在 Stand-along application 中使用 Glassfish 上的 Session Bean
2011年2月13日 星期日
在 Netbean+GlassFish 下開發 Sessiong Bean 及其 client 程式
本文件介紹如何使用 Netbeans 及 Glassfish 開發 Session Bean 及其 client 程式。內容包括:
2011年2月7日 星期一
網頁自動更新使用 meta refresh 指令
要讓 browser 能自動更新, 或者自動轉到另一個網頁使用指令:
為什麼要用 meta refresh 而不用 HttpServletRequest.sendRedirect() 方法呢? 因為 sendRedirect() 方法在重新導向時, 無法將 cookie 傳回伺服器端.
Reference:
* Meta refresh
* p174, 精通JAVA WEB程式設計, 葉雅美 - 維科出版社 ,2004-10-01 出版
<meta http-equiv="refresh" content="5" />為什麼要用 meta refresh 而不用 HttpServletRequest.sendRedirect() 方法呢? 因為 sendRedirect() 方法在重新導向時, 無法將 cookie 傳回伺服器端.
Reference:
* Meta refresh
* p174, 精通JAVA WEB程式設計, 葉雅美 - 維科出版社 ,2004-10-01 出版
Swing 的背景程式
要在 Swing 中執行背景程式, 要使用 SwingWorker 物件.
繼承 SwingWorker 物件後, 要覆寫 doInBackground(). 在 doInBackground() 中放的就是我們要執行的背景程式內容.
繼承 SwingWorker 物件後, 要覆寫 doInBackground(). 在 doInBackground() 中放的就是我們要執行的背景程式內容.
將字串編碼成 html 格式
在寫 servlets/JSPs 時, 常要要輸出符合 html 格式的字串, 例如:
"bread" & "butter" 要變成 "bread" & "butter"
有現成的套件可以做此轉換.
可以將字串轉成 html 的格式.
Reference:
* Apache Commons
* escapeHtml()
* Robin's Tech Tips
"bread" & "butter" 要變成 "bread" & "butter"
有現成的套件可以做此轉換.
org.apache.commons.lang.StringEscapeUtils 這個類別提供了: public static String escapeHtml(String str)可以將字串轉成 html 的格式.
Reference:
* Apache Commons
* escapeHtml()
* Robin's Tech Tips
2011年1月30日 星期日
Swing GUI 下背景工作程式
介紹在 Swing 程式下 javax.swing.SwingWorker。當在 Swing GUI 程式中要執行長時間的工作時, 可以利用 SwingWorker 物件, 把工作放到背景執行。 另外介紹在 Application framework (JSR 296) 下的 TaskService 及 TaskMonitor.
文件下載
文件下載
2011年1月28日 星期五
Swing layout
Swing layout 會自動的調整元件的大小, 不同的 layout 調整大小時所遵照的規則有所不同, 整理如下:
BoxLayout: requested maximum sizes
FlowLayout: preferred sizes
BorderLayout: preferred sizes
GridLayout: Each component takes all the available space within its cell, and each cell is exactly the same size
GridBagLayout: preferred sizes
BoxLayout: requested maximum sizes
FlowLayout: preferred sizes
BorderLayout: preferred sizes
GridLayout: Each component takes all the available space within its cell, and each cell is exactly the same size
GridBagLayout: preferred sizes
訂閱:
文章 (Atom)