2009-11-01

Difference between Linux and Windows (and similarity)

Linux, Mac, Solaris, BSD and some other OS share the same origin, grandfather UNIX, which make them having similar command and file structure. While Windows stands as its owned, has its owned unique command and structure that different from the UNIX bloodline. However all the OS are actually serve the same purpose, just that in different methods:

  1. File System Type: this is the type of method on how to format the hard disk. Currently Windows cannot browse hard disk (or partition) of Linux file system, however newer Linux can browse (or even modify) Windows file system.
    1. Windows: FAT and NTFS
    2. Linux: EXT2, EXT3 and EXT4
  2. File Structure: this is another thing that make Windows user confuse on Linux. In Windows, the file structure is based on hard disk, and then each hard disk can have more than 1 partition. For example C:\ is the hard disk and D:\ may be the second partition of the hard disk. However Linux treats hard disk and partition separately, which the structure will base on partition like /, /home, /etc and others.
    1. Linux /home is equivalent to Windows c:\document and settings
    2. Linux /bin and /sbin is equivalent to Windows c:\windows\system32
    3. Linux /opt is equivalent to Windows c:\program files
  3. Command: of course the commands between Linux and Windows are vary, but you can always find the equivalent command.
    1. List files: ls and dir
    2. Ping: ping (same for both OS)
    3. Change directory: cd (same for both OS)
    4. Make directory: mkdir (same for both OS)
    5. Copy: cp and copy
    6. Move: mv and move
    7. Delete: rm and del

2009-09-26

Tomcat configuration file - web.xml

Tomcat configuration file (web.xml) is using XML pattern, which the global configuration file is within tomcat\conf directory, and individual configuration file is within tomcat\wepapps\webdir\WEB-INF directory. User can always refer to the global configuration file as a sample to set the individual configuration file. The parent node of web.xml is <web-app> and below is the common nodes that can be used:

  1. Description for the web application.
    <description>
    Description for Web Application
    </description>
  2. Map the servlet to associate class and URL pattern.
    <servlet>
    <servlet-name>servlet name</servlet-name>
    <servlet-class>class name</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>servlet name</servlet-name>
    <url-pattern>url pattern</url-pattern>
    </servlet-mapping>

  3. Map the taglib to associate TLD files.
    <taglib>
    <taglib-uri>
    http://www.gnokproject.com/taglibs/taglib-v1.0
    </taglib-uri>
    <taglib-location>
    /WEB-INF/jsp/taglib.tld
    </taglib-location>
    </taglib>
  4. Map extension to associate mime type.
    <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html</mime-type>
    </mime-mapping>

  5. Session timeout.
    <session-config>
    <session-timeout>30</session-timeout>
    </session-config>
  6. First file to be accessed.
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>

2009-09-25

WEBAPPS directory structure

WEPAPPS is the directory that keep all the JSP files and JAVA files, and the place where people will get into when they are accessing Apache Tomcat. Inside WEBAPPS directory, each sub directory represents a sub directory in the URL, for example a sub directory named subdir represents www.gnokproject.com/subdir. Except for one directory called ROOT which represents the root directory www.gnokproject.com.

Inside each sub directory will have a directory called WEB-INF which contain:

  1. classes directory: keep the JAVA source files which will be auto compiled by Tomcat when the classes are needed.
  2. jsp directory: keep the TLD files or the tag library files.
  3. lib directory: keep the JAR files.
  4. web.xml: configuration files of that particular directory.

2009-09-23

Apache Tomcat directory structure

Tomcat's directory structure:

bin
Keep all execution files, for example startup.bat and shutdown.bat.
conf
Keep all the common configuration files, such as server.xml.
lib (in 6.0, or common, server, shared in 5.5)
Keep all the common classes and jar files that will be shared by all JAVA and JSP files in webapp.
logs
Keep all the log files.
webapps
Keep all the JSP files, where you normally spend most of the time here.
temp
Temporary directory.
work
Keep the caches compiled from JSP and JAVA files from wepapp.

Change Tomcat port from 8080 to 80

To change Apache Tomcat port from 8080 to 80 (so that developer or user doesn't need to type :8080 at the back of the URL):

  1. Edit TOMCAT_DIR\conf\server.xml.
  2. Look for line similar to below (the keyword is connector and 8080):
  3. Just change 8080 to 80 and restart Tomcat.

Setup Apache Tomcat to host JSP

JSP (Java Server Page) is Java based web programming language. Similar to ASP and ASPX (and different from PHP), JSP can be compiled into classes before used in the pages. To start coding in JSP, we need to setup Apache Tomcat first. Follow the steps below:

  1. Download JDK (Java Development Kit) from Java Website. Any version will do, but if you don't have any idea, just download and install the newest version.
  2. Download Apache Tomcat from Apache Tomcat Website. Currently there are versions 4.1, 5.5 and 6.0. Either version will do, or just pick the newest version.
  3. There are 2 types of Tomcat installation file, zip and windows installer. Either type is fine, or just download the zip version. Extract the zip file to any directory.
  4. Go to the Tomcat directory that you extracted (or installed), go to bin folder and edit the startup.bat file.
  5. Add the JAVA_HOME environment variable at the beginning of the startup.bat file (after @echo off)
    set java_home=C:\Program Files\Java\jdk1.6.0_16

  6. Then you may double click the startup.bat to start Tomcat. If a command terminal is shown without disappearing, it properly means OK.
  7. To test it out, open a browser and go to localhost:8080. If something come out (not the error message of course), that means you have setup Tomcat successfully.

2009-08-26

Oracle Net Manager

Net Manager is an utility come together with Oracle DBMS. User can find it inside Network Administrator at start menu or execute it by using command netmgr. Net Manager serves for 2 main purposes:

Set TNS Name at client PC. TNS name is the connection setting at client PC so that it is able to access database.

  1. Go to the tree navigator, select Service Naming and click add (green plus button at left panel).
  2. Set Net Service Name, what ever name you want.
  3. Set Network Type, which normally TCP/IP.
  4. Set Host Name and Port Number. Host Name you can either use IP address or DNS Name (if you got a DNS server at your network). While the default port is 1521.
  5. Set Service Name and Connection Type. Service Name is the name of the database, while Connection Type we can left it as default.
  6. Done.

Set Listener at Server. Listener is a process to accept connection from client and pass the connection to the database.

  1. Go to the tree navigator, select Listeners and click add (green plus button at left panel).
  2. Set what ever name you want for the listener.
  3. At the top of right panel, you can see a drop down box, which we need to set 2 things: Listening Location and Database Services.
  4. Listening Locations: add new a address, fill in Protocol (TCP/IP), Host (normally localhost will do where listener is resided together with the database) and Port (default 1521).
  5. Database Services: add new database, set Global Database Name and SID (both are the name of database) and Oracle Home Directory (where you install oracle DBMS).