發表文章

servlet 用get傳中文參數

from: response.sendRedirect("./change?reason=" + URLEncoder.encode("售完", "UTF-8")); ps.將中文轉為UTF-8的URL to: String reason = request.getParameter("reason"); reason = new String(reason.getBytes("iso-8859-1"),"UTF-8"); ps.接收端無法使用request.setCharacterEncoding("UTF-8")接收get過來的中文參數,只能使用getBytes reference http://openhome.cc/Gossip/Encoding/Servlet.html 原文轉貼如下: 請求參數的編碼處理,基本上必須分POST與GET的情況來說明,我們先來看POST的情況… 如果客戶端沒有在Content-Type標頭中設定字元編碼資訊(例如瀏覽器可以設定Content-Type: text/html; charset=UTF-8),此時使用HttpServletRequest的getCharacterEncoding()傳回值會是null,在這個情況下,容器若使用的預設編碼處理是ISO-8859-1(大部份瀏覽器預設的字元集) 你可以使用HttpServletRequest的setCharacterEncoding()方法指定取得POST請求參數時使用的編碼。例如若瀏覽器以UTF-8來發送請求,則你接收時也要使用UTF-8編碼字串,則可以在取得任何請求值之「前」,執行以下陳述: request.setCharacterEncoding("UTF-8"); 在HttpServletRequest的API文件中,對setCharacterEncoding()的說明清楚提到: Overrides the name of the character encoding used in the body of this request. 也就是說,這個方法對於...

jcaptcha

web.xml:     <servlet>         <servlet-name>jcaptcha</servlet-name>         <servlet-class>com.octo.captcha.module.servlet.image.SimpleImageCaptchaServlet</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>jcaptcha</servlet-name>         <url-pattern>/jcaptcha.jpg</url-pattern>     </servlet-mapping> web-inf/lib: commons-collections-3.2 commons-logging-1.0.4 filters-2.0.235 jcaptcha-2.0-alpha-1-SNAPSHOT jcaptcha-api-1.0 jcaptcha-integration-simple-servlet-2.0-alpha-1-SNAPSHOT jsp: <script type="text/javascript">     function refresh() {         var image = document.getElementById("jcaptcha.jpg");         image.src...

Cisco ASA5520設定

 Cisco ASA 5500-X Series Next-Generation Firewalls Configuration Guides http://www.cisco.com/c/en/us/support/security/asa-5500-series-next-generation-firewalls/products-installation-and-configuration-guides-list.html Configuring Interfaces (Transparent Mode) http://www.cisco.com/c/en/us/td/docs/security/asa/asa84/configuration85/guide/asa_cfg_cli_85/interface_complete_transparent.html Adding an IPv6 Access List http://www.cisco.com/c/en/us/td/docs/security/asa/asa82/configuration/guide/config/acl_ipv6.html Cisco guide document http://www.cisco.com/c/en/us/td/docs/security/asa/asa72/configuration/guide/conf_gd/intro.html ASA5520 compare http://www.cisco.com/web/HK/promotion_tc/asa5500_compare.html windows7 使用超級終端機連接RS232 COM1 PORT的3種方法 http://s90304a123.pixnet.net/blog/post/38498867 ASA password recovery https://supportforums.cisco.com/document/79016/asa-password-recovery Howto reset factory defaults Cisco ASA Series 5500 series 5505 5510 5520 http://ithelpblog...

SQL exists語法

圖片
Store_Information 表格 Store_Name    Sales Los Angeles    1500 San Diego    250 Los Angeles    300 Boston    700 Geography 表格 Region_Name    Store_Name East    Boston East    New York West    Los Angeles West    San Diego 查詢1 select sum(`sales`) from `store_information` as s where exists(     select * from `geography` as g     where `region_name` = 'West' ) 查詢2 select sum(`sales`) from `store_information` as s where exists(     select * from `geography` as g     where `region_name` = 'West'     and s.`store_name` = g.`store_name` ) 說明 EXISTS 運算子可以連接子查詢,用來判斷子查詢是否有返回的結果,如果有結果返回則為真、否則為假。若 EXISTS 為真,就會繼續執行外查詢中的 SQL;若 EXISTS 為假,則整個 SQL 查詢就不會返回任何結果。 故查詢1返回外查詢的結果 reference http://webdesign.kerthis.com/sql/sql_exists

NoSQL

http://blog.toright.com/posts/3809/mongodb-%E6%95%99%E5%AD%B8-linux-%E5%AE%89%E8%A3%9D-nosql-mongodb.html

RESTful

http://blog.toright.com/posts/1399/%E6%B7%BA%E8%AB%87-rest-%E8%BB%9F%E9%AB%94%E6%9E%B6%E6%A7%8B%E9%A2%A8%E6%A0%BC-part-ii-%E5%A6%82%E4%BD%95%E8%A8%AD%E8%A8%88-restful-web-service.html

JDBC出現unhandled exception type IllegalAccessException

狀況: 執行Class.forName(driverName).newInstance(); eclipse出現error訊息:unhandled exception type IllegalAccessException 原因: Class.forName("com.mysql.jdbc.Driver").newInstance(); 這行程式需要exception操作,要做try catch或throws, 而在jsp中,eclipse對於採用<% %>方式寫的程式碼不做異常檢查,因為JSP預設會做try catch。 解決方法:         try{             Class.forName(driverName).newInstance();         }         catch(Exception e){             //for catch Class.forName exception         }