Archive

Archive for December, 2008

The web application space

December 31st, 2008

One of the easy options to start developing in tomcat is to start drooping files in the <Tomcat Home>/webapps/ROOT folder. However, if you are planning to create deployable applications (.war) it is better to create a web application space in to tomcat. The process is not complicated, I found great help reading and following the indication in these web articles: Deploying Web Applications to TomcatDemystifying Tomcat 4’s server.xml FileHow to Create a Web Application in Tomcat Sever? 

In summary what it is necessary to do is the following:

  1. Create a folder for you new application in the <Tomcat Home>/webapps/ folder. Lets call it ‘newapp’.
  2. Inside newapp create the folder ‘WEB-INF’.
  3. Inside WEB-INF create the folders: classes and lib.
  4. Also create a file called ‘web.xml’ and put the following text in it: 
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
    
    <web-app>
    </web-app>
  5. Open to edit the file <Tomcat Home>/conf/server.xml and add the node <Context path=”/newapp” docBase=”newapp” debug=”0″ reloadable=”true” /> as a child of  the node <Host> and save it.
  6. For testing purposes create a file in <Tomcat Home>/webapps/newapp called test.jsp with this code in it: 
    <%
    	String message="Hello world!";
    %>
    <%= message %>
  7. Open you favorite internet navigator go to http://localhost:8080/newapp/test.jsp
  8. You have now a new web application space in tomcat.

It is possible to have many web application spaces in tomcat.

    Tomcat

    PHP to PDF

    December 23rd, 2008

    I had the task to populate a PDF form using PHP. There are many ways to do that, here is a very interesting one. However in my case the PDF form I need to work with had a part which was a graphic form included in the PDF. When the PDF was printed it did not look nice, acceptable but not nice.

    Because I wanted to learn how to create a PDF file with PHP I investigate for another way. I found a nice article about Generating PDFs with PHP which uses PDFLib. I didn’t decided to use it because it is a commercial product and the free option they offer (PDFlib Lite) is limited. I didn’t like also because is necessary to compile the library plus other related task. I am comfortable compiling software but in small projects this is to much I think.

    I wanted a free and fast option, so after searching and testing I become comfortable with FPDF. This is a class which is just add to the php code and you are ready to create PDFs. It is very easy to learn. I also found FPDI. This is a free class which allows to  import existing PDF documents into FPDF in order to add more elements to it. 

    I accomplished the task using this process:

    1. Design of the form using InDesign (CS4) to look exactly as the original millimeter by millimeter.
    2. Save the form as a PDF file.
    3. Create the PHP file.
    4. Load of the PDF file into FPDF using FPDI.
    5. Add the information text using FPDF functions in the specific places.
    6. Generate the new PDF file.
    7. Test in the navigator.
    8. Finish.

    The examples include in the FPDF and FPDI websites are self explanatory for all the necessary coding.

    PHP

    Git : Fast Version Control System

    December 20th, 2008

    An important area in software development is Revision control or Version Control. The most known software used for this kind of control, among others, are Concurrent Versions System (CVS) and Subversion (SVN). I was analyzing both of them trying to decided for the most convenient. A friend shared with me this interesting article: SNV vs CVS. I was almost deciding for SNV when I discover GIT.

    What called my attention is that Git was initially created by Linus Torvalds for Linux kernel development, according to what I found in wikipedia. This informations is also interesting:

    Several high-profile software projects now use Git for revision control, most notably the Linux kernel, Samba, X.org Server, Qt (toolkit), One Laptop per Child (OLPC) core development, Ruby on Rails web framework, VLC, Merb, Wine, SWI Prolog, DragonFly BSD and the Android mobile platform.

    There is available an OSX Installer for Git: git-osx-installer, and also a Git Eclipse Plugin.

    To install GIT in OSX is a matter of downloading the .dmg file and run the installer package found in it.

    Useful Link: 

    - Eclipse Git plugin installation

    A Tour of Git, with Java and Eclipse

    Git, Installations, Workstation

    Ant in Workstation

    December 18th, 2008

    Apache Ant is a Java-based build tool which Tomcat uses to deploy web applications. More info here: http://ant.apache.org. The steps I used to install Ant in the MacBook are:

    Download ANT from http://ant.apache.org/bindownload.cgi .
    Extract the Ant files into the folder you want to install it.
    Add the Ant /bin path to you ~/.profile file. In my case I added this line:
    export PATH=/Users/italoosorio/Tomcat/Ant-home/bin:$PATH 

    I am installing everything related to Tomcat development in my home/Tomcat folder.

    Helpful link:

    - http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/

    Ant, Installations, Tomcat, Workstation

    Tomcat in Workstation

    December 18th, 2008

    I decided to continue using JAVA as a programing language. I am using my laptop as developing environment, so I needed to install Tomcat in it. I followed the indication found in this web page: Installing Apache Tomcat 6 on Mac OS X Leopard. A summary of the steps used are the following:

    Set the JAVA_HOME environment variable

    Adding in the file ~/.profile the folling lines and restart the terminal:
    export JAVA_HOME=/Library/Java/Home
    export CATALINA_HOME=/Library/Tomcat/Home

    Download and install the Tomcat binarie

    Download Tomcat from the Apache Tomcat 6 Downloads Page
    Change directories to the folder where you want to install Tomcat.
    Create the Tomcat directory and set an appropriate owner and group:
    > mkdir Tomcat
    > chown <username> Tomcat
    > chgrp admin Tomcat
    Change directories to the newly created Tomcat directory and unpack the tar.gz files
    > cd Tomcat
    > tar -xvzf ~/Downloads/apache-tomcat-6.0.x.tar.gz
    Create a symbolic link that will always point to the current version Tomcat directory
    > ln -s apache-tomcat-6.0.x Home

    Edit tomcat-users.xml configuration file

    Change directories to the Tomcat configuration directory
    > cd Home/conf
    Edit the tomcat-users.xml file
    > nano tomcat-users.xml
    Add the following before </tomcat-users>, where <admin> is the administrator name you assign and <password> is the password. 
    <user username=”<admin>” password=”<password>” roles=”standard,manager,admin”/> 
    Save the tomcat-users.xml file and quit the editor

    Run and Test

    Change directories to where the Tomcat startup scripts are located
    > cd ../bin
    Remove the .bat scripts and .exe executables
    > rm *.bat *.exe
    Execute the Tomcat startup script
    > ./startup.sh
    Test in you navigator entering http://localhost:8080
    To stop Tomcat execute the strip shutdown.sd
    > ./shutdown.sh

     

    I am not planning to have Tomcat as daemon process, I wan to activate it manually.

    Installations, Tomcat, Workstation

    Welcome!

    December 18th, 2008
    Comments Off

    This blog was created with the objective to log my experiences while developing at SWAU. This will include the software and/or hardware I am using, the installation process, and my opinion result of my investigation of playing with them.

    You are welcome to give your feed back and share you experience which can help me to achieve my goals.

    Uncategorized