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

星期一, 12月 21, 2015

Java Web Services and Security 課堂筆記



  • 過去有PRC, RMI, COMBO,不過都過時了
  • Base64會做Binary大1/3倍,300KB=>400KB
  • XML定義
    • Well-Formed XML
      • 有PI
      • 唯一root
      • 對應的tag
      • 大小寫有分
    • Validated XML(Valid XML)
      • DTD
      • XML Schema
  • 歷史
    • XML已式微,但有其功能
      • 交換資料可驗證
        • ex, 潤年 2015-02-29(不需AP判斷)
    • SOAP也式微,但
      • 電子簽章等
      • 自己寫也可以... 所以有點雞肋
  • 名詞
    • AP Server
      • Web Container
      • EJB Container
      • 實做Jave EE製定的規格
    • Tomcat只有web container及實做一點點Java EE的規格
  • 名詞
    • REpresentational Service
      • 可output各式的format, json, xml, csv, ...
  • Convention
    • db命名單數 tb_member
    • RESTFul複數 members
  • JSON定義
    • [ { a: 1 } ] , 不合法(但可用),最上層要加{ }
    • [ ]的Security Issue
    • javascript會呼叫array construction,而js允許亡寫array的constructor,駭客可透過此攻擊系統
    • 修改方法:利用{ }包起來





星期四, 1月 21, 2010

到底啥係native,strictfp,transient,volatile

雖然考過SCJP都不知道幾年了
不過要我解釋native,strictfp,transient,volatile
還是支支吾吾說不出來
下定決心要看懂這四大天"字"是什麼意思

1. native
簡單講,呼叫其他語言(c,c++之類)做出來的dll
做法
1.利用java做個介面供其他語言實作(也就是宣告成native)
2.用javah產出.h;
3.用其他語言實現native方法
4.編譯成dll
5.在Java中,再用System.loadLibrary()方法讀dll,就成功啦

還是看原作的範例比較快
認識理解Java中native方法

2. strictfp
意思是FP-strict,精確浮點,符合IEEE-754規範的,那為什麼不一開始就符合規範咧?
看wiki是這麼說地
In older JVMs, floating-point calculations were always strict floating-point, meaning all values used during floating-point calculations are made in the IEEE-standard float or double sizes. This could sometimes result in a numeric overflow or underflow in the middle of a calculation, even if the end result would be a valid number.

3.transient
為了避免把password等之類機密的資料序列化儲在永久媒體(如硬碟)
因此只要將該變數宣告為transient,就會禁止此變數被序列化
用過hibernate後,就更能瞭解是什麼了


4. volatile
每次被thread執行時,都強迫重讀宣告為volatile的變數。
什麼意思咧?如同synchronized鎖定function的意思一樣,而volatile可直接對特定變數
看volatile的例子

嗯 要尊重原作 我就不再copy-paste了
其實是懶得貼 哈

不過~~總算都懂了...ya~~

Reference
認識理解Java中native方法
Java關鍵字之native,strictfp,transient,volatile

星期三, 2月 13, 2008

NoClassDefFoundError: org/jaxen/JaxenException

當使用dom4j,jdom等來讀xml時
會有NoClassDefFoundError: org/jaxen/JaxenException發生
因為dom4j不包含SAX與DOM"接口"
所以要多下載jaxen包

下載並解開取出jaxen.jar 引用即可以

星期一, 10月 08, 2007

利用panel放背景圖

JPanel panel = new JPanel()

{
protected void paintComponent(Graphics g)
{

// g.drawImage(ic.getImage(), 0, 0, null);

// Scale image to size of component
Dimension d = getSize();
g.drawImage(ic.getImage(), 0, 0, d.width, d.height, null);

// Fix the image position in the scroll pane

// Point p = scrollPane.getViewport().getViewPosition();
// g.drawImage(icon.getImage(), p.x, p.y, null);

super.paintComponent(g);
}
};
panel.setOpaque( false );
panel.setPreferredSize( new Dimension(400, 400) );
getContentPane().add( panel);

JButton button = new JButton( "Hello" );
panel.add( button );
panel.setBounds(getBounds());