Check out the Latest Articles:
J2EE – JNDI

To understand JNDI, the only thing you need to learn is naming.

Very simply example,

DNS is a naming convention which is used to map the domain to IP. Such as www.test.com – 9.161.142.75.

Another difficult thing to understand is LDAP (Lightweight Directory Access Protocol). most likely you will see it from the product where you have database storing all the users and you also have a LDAP server mapping all ther users as well (very popular usage).

Thus the LDAP name fn=Shengjie Min, p=SiChuan, c=CN names an LDAP entry fn=Shengjie Min, relative to the entry P=SiChuan,which in turn, is relative to C= CN.

So , back to the JNDI topic. JNDI allows us to look up any java object or LDAP directory based on the context. Hmm… not following..

Ok, one step by another,

1. Bindings

The association of a name with an object is called a binding. For example, a file name is bound to a file.

The DNS contains bindings that map machine names to IP addresses. An LDAP name is bound to an LDAP entry.

2. Context

A context is a set of name-to-object bindings

Examples are better than anything :) That’s why i like them.

eg. you have a few database source(JDBC), let’s say they are a few databases. The context would be those databases entries. And to find one of the specific data source out of them, you will need to do a look up among those entries(context).

Given a code snippet to help out:

Context initCtx = new InitialContext(); // actually, to create a brand new initialContext, which can take hashmap as argument, you construct the hashmap to contain name-value pair. Just think of it as defining the scope of the look up

Context envCtx = (Context) initCtx.lookup(”java:comp/env”);

DataSource ds = (DataSource) envCtx.lookup(”jdbc/raDataSource”);

J2EE – structure

J2EE components:

Application clients and applests components run on the client.

Servlet & JSP are web components run on the server

EJB components are business components run on the server

Generally, J2EE server is in Pink :)

Client <–> web tier(JSP/Servlet/Java Bean) <–>Business tier

More precisely,

Client <–> web tier(JSP/Servlet/Java Bean) <–>Business tier (Entity Bean/Session Bean/Message-Driven Bean) <–> DB Level

J2EE Containers:

Containers, no need to spend too much time here. Easy and Stupid.

  • Application client container
  • web container
  • EJB container
J2EE – Http Session

Very Simple Example。Http Session is stateless, keep track what user is doing.
SessionServlet
public class SersionServlet extends HttpServlet implements Servlet {
HttpSerssions session = request.getSession(false); //takes any two params, false, if user has session, give it to me; true, if user has no session, create one
if(session == null) {
session = reuqest.getSession(true);
session.setAttribute(”count”, hitCount);
}
[...]

jar command

//create Jar file
jar -cmf
c:create
f:file
m:manifast
eg. jar -cmf -C ./workspace/jar-test/classes myJarTest.jar *.class
//Extract Jar file
jar -xf
x:extract
f:file
eg. jar -xf myJarTest.jar
// update jar file
jar -uf
u: update

eg. jar uf foo.jar foo.class
//list jar file content as a table
jar -tf
t:table
eg. jar -tf myJarTest.jar

db2 geeks – we do everything by typing commands

Catalog remote node
catalog tcpip node db2node remote hostname server service_name
uncatalog node db2node

Catalog remote DB2 databases
catalog database db_name as alias_name at node db2node
uncatalog database dbname
List all odbc data sources
list system/user odbc data sources
catalog/uncatalog system/user odbc data source <data source name>
connect to database user name using password
Run sql scripts
To run a script, enter the following command:
db2 -f [...]

最简单的dojo学习笔记 – Part 2(create a widget)

<Create Your Own Widget Class/>
Creating a Widget Programmatically
var button1 = new dijit.form.Button(params, srcNodeRef);
eg.
new dijit.form.Button({ “class”: “large”, style: “color: red” }, dojo.byId(”someDiv”));
<div id=”someDiv” class=”large” style=”color:red”></div>
Creating a Widget declaratively
eg.
<div dojoType=”dijit.TitlePane” title=”Outer Pane”></div>
IMPORTANT:
startup()
Certain widgets require a startup() method to be called. Haha, java is here again just like GUI, rite?
accordion = new dijit.layout.AccordionContainer({}, dojo.byId(”accordionShell”));
accordion.addChild(new dijit.layout.ContentPane());
accordion.addChild(new dijit.layout.ContentPane());
accordion.addChild(new [...]