Friday, February 10, 2006

Usefull links

I keep on finding very usefull tutorials, here are some:

http://www.jspolympus.com/Struts/Struts.jsp

Here he is making a login

Handling cookies

http://husted.com/struts/

[Struts] Session variable

If you want to store data from the servlet and view this on the jsp, you can
do this by setting the variable in the session variable
this is done with this example code:

// get this session in the servlet
HttpSession session = request.getSession();

// retrieve the generated number, if not running for first time
Object genNumberObj = session.getAttribute("applGeneratedNumber");

// save the number in this session
session.setAttribute("applGeneratedNumber",new Integer(generated));

thanks to:
http://www.exadel.com/tutorial/struts/5.2/guess/strutstutorial-dynaform.html

Found another resource, this explains the use of session, application and request variables:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001565.htm

Thursday, February 02, 2006

More blog in the world

Although I'm very proud at my blog, there are others that have the same hobby as me.
Here is a blog that handles Webservices, UDDI and JAXR.
http://nitinweblog.blogspot.com/

I have just had a course about this and this is a topic that is most likely to be very popular in the future. Although I must confess that my exam was surely not great, I find this topic very interesting.
Here is someone who probably knows more about this then me.
Should someone have an other link/tutorial/example of this, do not hesitate to place your comments.

Should you want to highlight your blog, just send me a mail.
All programming topics are allowed.

[Hibernate] Manage the easy example

Previously I posted a easy hibernate mapping.
Here is the example manager class for this and a testcase main

The manager java class:
package hibernate.databaseTables;

import hibernate.HibernateSessionFactory;
import java.sql.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class UserManager {
    private Logger log;

    public UserManager(){
       log = Logger.getLogger(this.getClass());
    }

    public UserValue createUser(UserValue user) {
       log.info("creating User");
       Session session = HibernateSessionFactory.currentSession();
       Transaction tx = session.beginTransaction();
       Integer id = (Integer) session.save(user);
       user.setuserid(id);
       tx.commit();
       HibernateSessionFactory.closeSession();
       return user;
    }

    public void updateUser(UserValue user) {
       log.info("updating User");
       Session session = HibernateSessionFactory.currentSession();
       Transaction tx = session.beginTransaction();
       UserValue dbuser = (UserValue) session.get(UserValue.class, user.getuserid());

       if (user != null) {
          dbuser.setusername(user.getusername());
          dbuser.setpassword(user.getpassword());
          dbuser.setsurname(user.getsurname());
          dbuser.setfirstname(user.getfirstname());
          dbuser.setsex(user.getsex());
          dbuser.setaddress(user.getaddress());
          dbuser.setzipcode(user.getzipcode());
          dbuser.setcity(user.getcity());
          dbuser.setemail(user.getemail());
          dbuser.setphone(user.getphone());
          dbuser.setmobile(user.getmobile());
          dbuser.setdateofbirth(user.getdateofbirth());
       }
       session.flush();
       tx.commit();
       HibernateSessionFactory.closeSession();
    }

    public void listUser() {
       log.info("list User");
       Session session = HibernateSessionFactory.currentSession();
       Transaction tx = session.beginTransaction();
       List UsersList = session.createQuery("from UserValue").list();
       for (Iterator iter = UsersList.iterator(); iter.hasNext();) {
          UserValue user = (UserValue) iter.next();
          System.out.println("Id " + user.getuserid() + " Name " + user.getusername());
       }
       tx.commit();
       HibernateSessionFactory.closeSession();
    }

    public void tc_UserManager(){
       // testcase to create a user to the DB
       UserValue user=new UserValue();
       user.setaddress("tiensestraat");
       user.setcity("zichem");
       user.setdateofbirth(new Date(0));
       user.setemail("nico.beylemans@gmail.com");
       user.setfirstname("nico");
       user.setmobile("0478/540878");
       user.setpassword("eenwachtwoord");
       user.setphone("geen");
       user.setsex(false);
       user.setsurname("beylemans");
       user.setusername("beyle");
       user.setzipcode(3271);
       try{
          user=this.createUser(user);
          this.listUser();
       } catch (HibernateException e) {
          // problem with Hibernate happened
          e.printStackTrace();
       }
       System.out.println("primary key is " + user.getuserid());
    }
}

The main testcase class:
package hibernate;

import hibernate.databaseTables.ApplicationManager;
import hibernate.databaseTables.PermissionManager;
import hibernate.databaseTables.RoleManager;
import hibernate.databaseTables.TariffTypeManager;
import hibernate.databaseTables.UserManager;
import hibernate.databaseTables.UserRoleManager;

public class TestAsApplication {
   public static void main(String[] args) {
       // Testcases
       //testing UserManager OK
       UserManager usermanager=new UserManager();
       usermanager.tc_UserManager();
    }
}

[Hibernate] Easy mapping example

As I 'm finally getting to know Hibernate basics, I managed to make all the mappings for my database. Here is an example for User

Some explanation, the database table is tbl_user, the persistence class is UserValue and the mapping is made in User.hbm.xml, Here are the example files:

SQL code create table tbl_User for postgreSQL:
create table "public"."tbl_permission" (
    permissionid serial,
    applicationid serial,
    roleid serial,
    autorizations text,
    begindate date,
    enddate date,
    constraint "pk_permission" primary key (permissionid),
    constraint "permissionsonapplication" foreign key (applicationid)
       references "tbl_application" (applicationid),
    constraint "rolehaspermissions" foreign key (roleid)
       references "tbl_role" (roleid)
);

The java persistence class UserValue:
package hibernate.databaseTables;
import java.sql.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;

public class UserValue {
    private Integer userid=0;
    private String username="";
    private String password="";
    private String surname="";
    private String firstname="";
    private boolean sex=false;
    private String address="";
    private Integer zipcode=0;
    private String city="";
    private String email="";
    private String phone="";
    private String mobile="";
    private Date dateofbirth=new Date(0);
    public String getaddress() {
       return address;
    }
    public void setaddress(String address) {
       this.address = address;
    }
    public String getcity() {
       return city;
    }
    public void setcity(String city) {
       this.city = city;
    }
    public Date getdateofbirth() {
       return dateofbirth;
    }
    public void setdateofbirth(Date dateofbirth) {
       this.dateofbirth = dateofbirth;
    }
    public String getemail() {
       return email;
    public void setemail(String email) {
       this.email = email;
    }
    public String getfirstname() {
       return firstname;
    }
    public void setfirstname(String firstname) {
       this.firstname = firstname;
    public String getmobile() {
       return mobile;
    }
    public void setmobile(String mobile) {
       this.mobile = mobile;
    }
    public String getpassword() {
       return password;
    }
    public void setpassword(String password) {
       this.password = password;
    }
    public String getphone() {
       return phone;
    }
    public void setphone(String phone) {
       this.phone = phone;
    }
    public boolean getsex() {
       return sex;
    }
    public void setsex(boolean sex) {
       this.sex = sex;
    }
    public String getsurname() {
       return surname;
    }
    public void setsurname(String surname) {
       this.surname = surname;
    }
    public Integer getuserid() {
       return userid;
    }
    public void setuserid(Integer userid) {
       this.userid = userid;
    }
    public String getusername() {
       return username;
    }
    public void setusername(String username) {
       this.username = username;
    }
    public Integer getzipcode() {
       return zipcode;
    }
    public void setzipcode(Integer zipcode) {
       this.zipcode = zipcode;
    }
    public void reset(ActionMapping mapping, HttpServletRequest request) {
       username=null;
       password=null;
       surname=null;
       firstname=null;
       sex=false;
       address=null;
       zipcode=null;
       city=null;
       email=null;
       phone=null;
       mobile=null;
       dateofbirth=null;
    }
}

The mapping file UserRole.hbm.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
    <class name="hibernate.databaseTables.UserRoleValue"
       table="tbl_userrole">
    <id name="userroleid" column="userroleid"
      type="java.lang.Integer">
       <!-- postgresql -->
       <generator class="sequence">
          <param name="sequence">tbl_userrole_userroleid_seq</param>
       </generator>
    </id>

    <property name="userid" column="userid" type="java.lang.Integer" />
    <property name="roleid" column="roleid" type="java.lang.Integer" />
    <property name="begindate" column="begindate" type="java.sql.Date" />
    <property name="enddate" column="enddate" type="java.sql.Date" />

    </class>
</hibernate-mapping>

Tuesday, January 31, 2006

Design patterns II


Some time ago I mentioned "design patterns"
For who doesn't know what it is, design patterns are a way to program code so that it is maintainable. If you could make an application using design patterns, when the application should change, the impact on the code would be minimized.
Now I know what you think, these small parts of code and rules must be known and this theoretical approach can be boring.
This means that you have never heard of head first labs
Not only have they captured all the patterns in one book (or on the poster).
They made the book readable like a magazine (a good one).
Look at there website and you 'll know what I mean:
http://www.headfirstlabs.com/index.php


Note: If you should be somewhere at a conference and find someone of the head first labs crew, please tell them to sell there book "Bring you own brain". I really want a copy to impress my friends :-)

Note2: telling the books name three times, will not expose the patterns guru, does anyone have another idea (have anyone seen his lamp)?
Read the book...

Monday, January 30, 2006

[Struts] Passing data to the jsp

This code was made found at http://www.allapplabs.com/struts/struts_example.htm
It shows how you can pas data from one jsp to another.
This is struts basic and very easy but I didn't knew this.

first jsp contains the code:
<html:text property="name" />

The struts action mapping creates a action class.
This class loads the data from the form with the code:
NameForm nameForm = (NameForm)form;
String name = nameForm.getName();

Second this class sets the attribute for the second jsp:
request.setAttribute("NAME", name);

The second jsp page loads the data with the code:
<%= request.getAttribute("NAME") %>

How easy can it be :-)

Saturday, January 28, 2006

Still learning hibernate

I'm still searching to expand my knowledge on Hibernate.
Although I already found some advantages of Hibernate But this is still only the beginning, there is much more to learn.
Now I have set my hope on the following links:

Not only hibernate but also struts and tiles can be found here:
allapplabs

The homepage of Michael Glogls, an hibernate expert:
gloegl

Friday, January 20, 2006

An example dir structure of our project

Struts tiles

When making a more complex web application, you can use tiles to format your web layout. Instead of making a link to a jsp page, you 'll link to a tile which is a split up of the screen into more different jsp pages.

There is a tiles plugin for struts, you can include it in the struts-config.xml file.
When you are working module based, also the tiles are module based in each struts-config.xml file.

An example:
WEB-INF/struts-config.xml
   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
      <!-- Path to XML definition file -->
      <set-property property="definitions-config"
         value="/WEB-INF/tiles-defs.xml" />
      <!-- Set Module-awareness to true -->
      <set-property property="moduleAware" value="true" />
   </plug-in>

The tiles are defined in the file:
WEB-INF/tiles-defs.xml
   <definition name="base.Tile4Rows" path="/view/tiles/Tile4Rows.jsp">
      <put name="header" value="/view/common/template.jsp" />
      <put name="navigation" value="/view/common/template.jsp" />
      <put name="body" value="/view/common/template.jsp" />
      <put name="footer" value="/view/common/template.jsp" />
   </definition>
This is a base tile containing 4 jsp pages.
Please notice that the value of the pages are defined from the root !!
Ex. /view/common/template.jsp
The base if this tile is a jsp page Tile4Rows.jsp
In this page which is a html with the tiles pages placed as:
view/tiles/Tile4Rows.jsp
   <tiles:insert attribute="body" />

The mapping to these tiles is identical as a normal mappig
WEB-INF/struts-config.xml
   <action
      path="/startWebPage"
      type="tiles.TilesForward">
      <forward name="success"       path="Homeframe"/>
   </action>

The Homeframe that is called here can also be found in the
WEB-INF/tiles-def.xml
   <definition name="Homeframe" extends="base.Tile4Rows">
      <put name="header" value="/view/common/header.jsp" />
      <put name="navigation" value="/view/common/menu.jsp" />
      <put name="body" value="base.Tile2Columns" />
      <put name="footer" value="footerframe" />
   </definition>>


Note: the "body" of this tile is again split up in a new tile base.Tile2Columns and so on...

Struts validator plugin

People working with struts know that when you have a form, you can create a form bean that 'll automatically load the form data. in older projects, this class that is created must extend ActionForm and contains a method validate.
This is depreciated, a better way is to include the validator plugin.

The validator plugin works with a other class for the form data.
Now the class created with the form data must extend ValidatorForm, it also must implement Serializable.
This class doens't contain the method validate nay more, the validation is now done with the xml file.
This is included in the struts-config.xml files of that module like:
WEB-INF/examplemodule/struts-config.xml
   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
      <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/examplemodule/validation.xml" />
      <set-property property="stopOnFirstError" value="true" />
   </plug-in>

The validation of the form in the "examplemodule" module can now be found in the file:
WEB-INF/examplemodule/validation.xml
Here is some example code in this file:
 <form-validation>
   <formset>
      <form name="submitForm">
         <field>
            Describe a field from the form
         </field>
      </form>
   </formset>
 </form-validation>

Struts setup more struts-config.xml files module based

When making a larger project, you can best make more than one config files to keep the project maintainable.
This can be done by splitting up the project into modules.
More struts-config files are included in the file:
WEB-INF/web.xml
   <init-param>
      <param-name>config/form</param-name>
      <param-value>/WEB-INF/form/struts-config.xml</param-value>
   </init-param>

Here you included a struts-config.xml file for a module named "form"
To start that module, used the link in a jsp page example:
menu.jsp
<html:link module="/form" action="/startform">Start module</html:link>

Please take in mind that this 'll also set the root dir in all action links to the /form directory automatically !!
So if you look in the config file:
WEB-INF/form/struts-config.xml
   <action-mappings>
      <action path="/startform" forward="/index.jsp" />

The forward /index.jsp 'll actually open the file from the root:
form/index.jsp

A struts-blank flow

Yesterday, I posted the struts-blank directory structure.
Now let me explain the flow that this struts-blank handles.

index.jsp
   <logic:redirect forward="welcome"/>

WEB-INF/struts-config.xml
global forward:
   <forward
     name="welcome"
     path="/Welcome.do"/>

action mapping:
   <action
     path="/Welcome"
     forward="/pages/Welcome.jsp"/>

pages/Welcome.jsp
   <bean:message key="welcome.message"/>

WEB-INF/struts-config.xml
   <message-resources parameter="MessageResources" / >

WEB-INF/src/java/MessageResources.properties
   welcome.message=To get started on your own ...

How to give an example with tags

I wanted to post a flow of struts yesterday but I had a lot of troubles that I could
not display a tag onto this page.
Now I found the code to display the tags and some other special characters:

< is done with "& lt;"
> is done with "& gt;"
& is done with "& amp;"
  is done with "& nbsp;"
© is done with "& copy;"

Thursday, January 19, 2006

Struts blank default directory structure

|---index.jsp
|
+---META-INF
|        MANIFEST.MF
|
+---pages
|        Welcome.jsp
|
+---WEB-INF
|       |    .cvsignore
|       |    struts-bean.tld
|       |    struts-config.xml
|       |    struts-html.tld
|       |    struts-logic.tld
|       |    struts-nested.tld
|       |    struts-tiles.tld
|       |    tiles-defs.xml
|       |    validation.xml
|       |    validator-rules.xml
|       |    web.xml
|       |
|       +---classes
|       |       |    build.xml
|       |       |     MessageResources.properties
|       |       |    README.txt
|       |       |
|       |       \---java
|       |             MessageResources.properties
|       |
|       +---lib
|       |    antlr.jar
|       |    commons-beanutils.jar
|       |    commons-digester.jar
|       |    commons-fileupload.jar
|       |    commons-logging.jar
|       |    commons-validator.jar
|       |    jakarta-oro.jar
|       |    struts.jar
|       |   
|       \---src
|             |    build.xml
|             |    README.txt
|             |   
|             \---java
|                      MessageResources.properties
|            
\---work
       |    tldCache.ser
       |
       \---org
             \---apache
                      \---jsp
                            |    index_jsp.class
                            |    index_jsp.java
                            |
                            \---pages
                                     Welcome_jsp.class
                                     Welcome_jsp.java

Learning struts

When starting to learn struts, here is a link with a lot of helpful tutorials.

Java boutique
RoseIndia

Struts is based on the MVC principle:
- The Model: System State and Business Logic
"The Struts framework architecture is flexible enough to support most
any approach to accessing the Model, but we strongly recommend that
you separate the business logic ("how it's done") from the role that
Action classes play ("what to do"). 'nuff said."
- The View: JSP Pages and Presentation Components
"The View portion of a Struts-based application is most often constructed
using JavaServer Pages (JSP) technology. JSP pages can contain static HTML
(or XML) text called "template text", plus the ability to insert dynamic
content based on the interpretation (at page request time) of special
action tags."
- The Controller: ActionServlet and ActionMapping
"The Controller is focused on receiving requests from the client (typically
a user running a web browser), deciding what business logic function is to
be performed, and then delegating responsibility for producing the next
phase of the user interface to an appropriate View component."
"An ActionMapping defines a path that is matched against the request URI of
the incoming request and usually specifies the fully qualified class name
of an Action class. All Actions are subclassed from
org.apache.struts.action.Action. Actions encapsulate calls to business logic
classes, interpret the outcome, and ultimately dispatch control to the
appropriate View component to create the response."

Monday, January 16, 2006

Design patterns

Some time ago I discovered the book head first desing patterns.
This is the best book I have ever red,
if you share my enthausiasme, please let me know.

For the freaks, a list of the patterns:

  • Adapter pattern
  • Bridge pattern
  • Builder pattern
  • Chain of responsibility pattern
  • Command pattern
  • Composite pattern
  • Decorator pattern
  • Facade pattern
  • Factory method pattern
  • Flyweight pattern
  • Interpreter pattern
  • Iterator pattern
  • Mediator pattern
  • Memento pattern
  • Observer pattern
  • Prototype pattern
  • Proxy pattern
  • Singleton pattern
  • State pattern
  • Strategy pattern
  • Template method pattern
  • Visitor pattern

More on this later ...

Hibernate error: identifier of an instance of ... was altered

My error:
identifier of an instance of hibernate.databaseTables.TariffTypeValue was altered from 7 to 0
After some search, the error must be due to the code:
Integer id = (Integer) session.save(TariffType);
TariffType.settarifftypeid(id);
And what was the problem, simple, in the TariffTypeValue class which is my persistence class,
I had the following code to set the ID:
tarifftypeid = tarifftypeid;
Change this to
this.tarifftypeid = tarifftypeid;
and the error 'll be solved.
This was a very easy and stupid error but the error message made it confusing.

Hibernate case sensitive

Today I have spend most of my day with Hibernate solving the stupid case sensitive problem. Thank you stdunbar and Outlaw at dev-shed
http://forums.devshed.com/java-help-9/question-about-hibernate-318157.html

Another useful forum for java, Struts and Hibernate
http://forums.hotjoe.com/

Hibernate error when listing data

Ok this is an error I'm currently having with hibernate when loading data from the DB.
I'm starting to learn hibernate .
I have made a test caseI finally made this work, even within a struts project.
Now I thought I had it all, I found a problem in my code.
I have made the database table in postgreSQL and made a java persistent class, I also made a mapping file.
I tested this by storing some data in my DB which worked perfect so I guess this means that all my files for hibernate are ok.
Now when I want to print a list from the db, I get the following

error :org.hibernate.hql.ast.QuerySyntaxException: tbl_tarifftype is not mapped.
[from tbl_tarifftype]at.....Caused by: tbl_tarifftype is not mapped
....
22 more
I used the code from several examples I found on the www which should work but in my case they don't.
This is the code to show the list:
public void listTariffType() {log.info("list TariffType");
Session session = HibernateSessionFactory.currentSession();
Transaction tx = session.beginTransaction();
List TariffTypeList = session.createQuery("from tbl_tarifftype").list();
for (Iterator iter = TariffTypeList.iterator(); iter.hasNext() {
TariffTypeValue TariffType = (TariffTypeValue) iter.next();
System.out.println("Id " + TariffType.getTariffTypeID() + " Name " + TariffType.getName());
}
tx.commit();
HibernateSessionFactory.closeSession();
}

Answer to the problem:
change List TariffTypeList = session.createQuery("from tbl_tarifftype").list();
to
List TariffTypeList = session.createQuery("from TariffTypeValue").list();
Thanks to http://forums.devshed.com/java-help-9/question-about-hibernate318157.html
user: stdunbar

Also a very helpful comment on this same forum thread from
user Outlaw:
guess it'll be wrong but try to change "tbl_TarifType" to lower case everywhere long ago i had a problem with table namesguess in postgreSQL names might be in lower case
INDEED USE SMALL CAPITALS IN POSTGRESQL...
Thanks guys

So far so good

Until now, all the posts were made by me in the past before I leaned about blogger.
From this moment, I 'll continue developing our website application and post whenever I find/learn some useful information.
Should you have any question, you may always email me.

How far do we stand:
Here is a small overview of the used tools
  • java SDK
  • eclipse
  • tomcat server
  • struts
  • struts validation plugin
  • struts tiles
  • postgreSQL
  • hibernate

Persistence layer Hibernate

We have a website on struts, we have installed a database, now we want to connect the webapp with the database.
You can do this simply using java code but what if you want to change from database vendor.
Then there is a lot of recoding as all these vendors use there own version of SQL.

With hibernate, changing database type, is changing the three lines of code that setup the database connection in the hibernate.cfg.xml file.
This is the example code to setup hibernate and postgreSQL.

pgsql-de-komma
jdbc:postgresql://localhost/deKomma
postgres
org.postgresql.Driver
org.hibernate.dialect.PostgreSQLDialect
*******

This is not a hibernate tutorial, I just want to show how I set it up.
If you have any question, please do not hesitate to contact me.

The database PostgreSQL

If you want to make a website, you probably want to store some information.
This is done in a database, a free one we used is postgreSQL.
You can just download it from there website.

In this package, there is a admin III tool which makes it easy to make a database, create a table and the references. Just try is, it speaks for itself.

Struts

We have our first webapp, now we can include struts, this is as easy as download it from the struts website, unpack the jar file.
Now look in eclipse and import in your webapp the struts-blanc jar file.
Now open your project on the server and you should see a nice welcome page from struts.

This example from struts looks easy, but actually there is a full flow exposed.
Here is the past of the code for this flow.
The files are bold, the code in that file is italic

index.jsp
<logic:redirect forward="welcome">
WEB-INF/struts-config.xml
<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
</global-forwards>
<forward path="/Welcome.do" name="welcome">
</GLOBAL-FORWARDS>

The Welcome.do means do action welcome later in that file
<action
path="/Welcome"
forward="/pages/Welcome.jsp"/>

So, the website starts with index.jsp and automatically loads pages/Welcome.jsp which is the page you seen when you opened your webapp.

This is not a full manual for struts, this is not my intention, I just want to give a small presentation how I set it up and more focus on the errors I have had and hopefully solved.

Should you have a question, please do not hesitate to contact me.

Our first webapp

All is ready to make our first webapp.
Just start a new tomcat project from Eclipse.
Make sure to enable the project to update the server.xml file so that the project is automatically published on the server.

Plugin Eclipse

When developing a website, you can be sure there 'll be a time that you are going to make some exceptions. Our tomcat is so smart to throw these for you, only to find them in the log files of tomcat. Luckily there is a plugin for eclipse that allows you to run tomcat from within eclipse. This is nice but even better is that the log files from tomcat are shown in the eclipse console window. How great is that.
You can find the plugin and the doc for installing it on
http://www.sysdeo.com/eclipse/tomcatplugin

Development tool Eclipse

Now we have a webserver, we decided which framework to use now we can start.
Our framework depends on the java programming language which we installed
Now we need a good develop tool for this.
We probably found the best one, and it is free.You can download it from http://www.eclipse.org/

Download the file and run the exe.

Programming language java SDK

Our website is going to be designed in the java language.
You can download the java kits from
http://java.sun.com/

We have used the J2EE 1.4 SDK

One of the biggest reasons why I'm a fan of java is because the have an enormously number of classes already made for you, the manual of these classes is called the API, this can be found at
http://java.sun.com/j2ee/1.4/docs/api/index.html

Tomcat webserver

When starting to create a dynamic website, first you can best setup yourself a webserver.
We have chosen for Tomcat, you can download the latest tomcat server from
http://tomcat.apache.org/
Installing this on a Windows environment is as easy as downloading the exe file and click on it.

After installing the tomcat server, you can find some useful files in the installation dir.
Note: we use tomcat 5.5, these files can change according to the version you use.
  • conf/server.xml: here you can set the location of your web applications.
    Standard location is under de webapp dir but in this file you can also specify some
    webapps on a other location.
  • conf/tomcat-users.xml: here you can specify the users on the server with there passwords.

Framework

So our java framework 'll be struts action with hibernate on postgreSQL.
Also all these things are going to be programmed using design patterns.

Idea

The idea for this blog came from my graduation task.
For this we 're going to make a website.
You can make a website easily when using only static html but we would like
to make a dynamic website.
Because we have had two years lessons on java, we decided to use a java based website.
This includes servlets or jsp's. Now both have there advantages and what if you now can use both. This is possible with the use of a good framework.

Knowing this we searched for a framework and decided to use the struts action framework.
Furthermore we include in this framework the validation and tiles plugins and expand this with a database (we use postgreSQL) and a persistence layer for which we used Hibernate.

All this can only be made using a good design, what is a good design ? Well some smart people made a lot of design structures which you can follow, they called them design patterns.

So to make our website, we need to understand these all.
How I'm doing this, I'll post here with all my suggestions and all I can find.
Should you read this and have some other helps/suggestions, please feel free to post them.