Monday, July 02, 2007

struts2 + spring + hibernate

(If u don't how struts2+spring works, see struts2+spring workflow)

What i'm trying do to here:
i have a table named "User" in our database.
now i want to build a web-application using struts2+spring+hibernate
1. to add new user to database and
2. to log in to home page for existing user.

Download sourcecodes

Files (java/xml) i'll create for this:

1. "User" table in database.

2. User.java:
which will be mapped with that "User" table.
3. User.hbm.xml:
that maps User table with User.java.
4. IUserDao.java:
interface for data access object.
5. UserDAOHibernateImpl.java:
which implements IUserDao.java
6. IUserService.java:
interface for service
7. UserServiceImpl.java:
which implements IUserService
8. UserAction.java:
action class for struts2
9. applicationContext.xml:
Register your objects via the Spring configuration.
all the above files and data source will be configured here.
10. struts.xml:
its the configuration file for struts2 (which was struts-config.xml for struts1)
11. output *.jsp files, i've used 3 here:
11.i) addUser.jsp: to add new user in DB
11.ii) login.jsp: to log in existing user
11.iii) hello.jsp: says hello to the user after successful log in.
12. xml files for validation
13. and good old web.xml

jar files we need are same as this example

so now.......Ready... Set... GO!

1.Let, database used is mysql. database name ExampleDB and table name User.


create database ExampleDB;
use ExampleDB;
create table User(
name varchar(20),
id
varchar(20) not null primary key
);





2. write the web.xml file:

In the web.xml file, Struts defines its FilterDispatcher, the Servlet Filter class that initializes the Struts framework and handles all requests.

If you don't know how to write web.xml for struts2, see web.xml

In most cases, we can simply use web.xml for struts2-blank template. we just need to add the following lines to configure the Spring listener.

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener

</listener-class>
</listener>



Everything else is same as any other web.xml for struts2.

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="example" version="2.4"
xmlns=
"http://java.sun.com/xml/ns/j2ee"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>


<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>

</filter-mapping>

<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener

</listener-class>
</listener>

</web-app>





3.write User.java file that will be used to map the User table.

package com.example.user; 

public class User {

private String id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {

this.name = name;
}
/** * @return Returns the userId. */

public String getId() {
return id;
}

/** * @param userId The userId to set. */
public void setId(String userId) {
this.id = userId;
}

}






4.Now maps the database table with .java file. To do this, write the mapping file, User.hbm.xml :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >


<!--Maps User.java class with User
database table -->


<hibernate-mapping>
<class name="com.example.user.User"

table="User">


<id name="id" column="id" >
<generator class="assigned" />

</id>
<!--
id tag represents the primary key of
database table generator class defines
how key will be generated.
Here we've choose "assigned", that is key will be
assigned before insert.
Other generator classes are:
1.native
2.increment : auto increment the key value
-->


<property name="name" column="name" />

<!--
property tag maps columns other than
the primary key column.
-->


</class>
</hibernate-mapping>



Put all your *.hbm.xml files in com/example/user/hbm folder.

5.Write the Data Access Object that would be used to access database using hibernate.
At first we would write the interface : IUserDao.java

package com.example.user ; 
public interface IUserDao {
public String addUser(User user);
public User findUserById(final String Id);


}

//Now write UserDAOHibernateImpl.java :

package com.example.user;
import org.springframework.orm.
hibernate3.HibernateTemplate;

public class UserDAOHibernateImpl
implements IUserDao
extends HibernateDaoSupport
{


public String addUser(User user){
String success;
try{
getHibernateTemplate().save(user);
success="Welcome !";
}
catch(Exception e){
success="Sorry, user cannot be added";
}
return success;
}

public User findUserById(final String id){

return (User)

getHibernateTemplate().get(User.class, id);
}

}






getHibernateTemplate().save(user) would insert user into the User database table
we've used HibernateTemplate because it provides easy method to do basic queries and also it is thread safe.
get method will return the user object with given id if such an user existed, otherwise null will be returned.

6. Write the service class (it would seem a little redundant at first, but it's the best practice to provide service layer between action and dao class).
Usually database transaction management is applied on this layer.
//Interface for service class:

package com.example.user;

public interface IUserService {
public String add(User user);
public User findById(final String Id);

}

//Service class: UserServiceImpl.java

package com.example.user;
public class UserServiceImpl implements IUserService{

private IUserDao userDao;

public IUserDao getUserDao() {
return userDao;
}
public void setUserDao(IUserDao userDao) {

//userDao will be set by applicationContext.xml

this.userDao = userDao;
}

public String add(User user){
String result=userDao.addUser(user);
return result;
}
public User findById(String Id){
User user=userDao.findUserById(Id);
return user;
}

}





7.At last, now write the action class: UserAction.java
Here our action class will
1.take the user id
2.retrieve user name from database
3.and say " Hello <user name>"
4.add new user

package com.example.user; 

import java.util.Map;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext ;


public class UserAction {
private IUserService userService;
private User user;
private String id;
private String name;

/** * Constructor * @param userService */
public UserAction(IUserService userService)
{

this.userService=userService;

// will be set by applicationContext.xml
}
public String execute() {
this.user=

(User)userService.findById(this.id);
String result;
if(user==null){

// returns error if user doesn't exist.

result="User id does not exist";
ActionContext.getContext().
getSession().

put("result", result);
return Action.ERROR;
}
else {
result="";
ActionContext.getContext().
getSession().
put("user", user);

// puts user object in session
return Action.SUCCESS;
}
}
public String signup(){
return Action.SUCCESS;
}
public String addUser(){
String result;
this.user=

(User)userService.findById(id);
if(user==null){
user=new User();
user.setId(this.id);
user.setName(this.name);
result=userService.add (user);
ActionContext.getContext().
getSession().
put("user", user);
}
else{
result="Id already used,
Choose another Id"
;
ActionContext.getContext().
getSession().
put("result",result);

return Action.ERROR;
}
ActionContext.getContext().
getSession().
put("result", result);
return Action.SUCCESS;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}


}



8.Write the jsp files: we will use 3 jsps here
1.login.jsp: take the id from user
2.hello.jsp: say hello
3.addUser.jsp: add a user



login.jsp:
<%@ taglib prefix="s" uri="/struts-tags"%>

<html >
<head>
<title>Log in</title>
</head>
<body>
<h2><s:property value="#session.result"/></h2>
<s:form action="SignIn" validate="true">
<s:textfield label="User Id" name="id" required="true"/>
<s:submit value="Login" />
</s:form>
<a href=" <s:url action="SignUp"/> "> Sign Up As A New User </a>
</body>

</html>
---------------------------------------------------------------
hello.jsp
<%@ taglib prefix="s" uri="/struts-tags"%>
<html >
<head>
<title>Hello</title>
</head>
<body>
<s:if test="#session.user!=null">
<h2>Hello <s:property value="#session.user.name"/></h2>
</s:if>
</body>

</html>
--------------------------------------------------------------------
addUser.jsp
<%@ taglib prefix="s" uri="/struts-tags"%>
<html >
<head>
<title>Sign Up</title>
</head>
<body>
<s:property value="#session.result"/></h2>
<s:form action="add" validate="true">
<s:textfield label="User Name " name="name" required="true"/>
<s:textfield label="User Id" name="id" required="true"/>
<s:submit value="Submit"/>
</s:form>
</body>

</html>





9. Write the applicationContext.xml file:

<?xml version=" 1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">


<!--
- Application context definition
-->
<beans>
<!-- ========================= RESOURCE DEFINITIONS ========================= -->

<!-- Creating a data source connection pool-->

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource ">


<property name="driverClassName">

<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/ExampleDB</value>

</property>
<!-- Provide username and password for mysql -->
<property name="username" value="root"/>
<property name="password" value=""/>



</bean>


<!-- Hibernate SessionFactory -->

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">


<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingDirectoryLocations">
<list>

<value>classpath:/com/example/user/hbm</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">

org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- show the sql command in console -->
</props>
</property>

</bean>



<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

<!--
Data access object: Hibernate implementation.
-->


<!-- with transaction -->
<bean id="hibernateTemplate"

class="org.springframework.orm.hibernate3.HibernateTemplate">

<property name="sessionFactory">
<ref bean="sessionFactory"/>

</property>
</bean>

<bean id="UserDaoImpl" class="com.example.user.UserDAOHibernateImpl">
<property name="hibernateTemplate">

<ref bean="hibernateTemplate"/>
</property>
<!-- set HibernateTemplate in UserDAOHibernateImpl.java class-->
</bean>

<!--
Defination of service targets
-->

<bean id="UserServiceTarget"

class="com.example.user.UserServiceImpl">

<property name="userDao">
<ref bean="UserDaoImpl"/>

</property>
<!-- set IUserDao in UserServiceImpl.java class-->
</bean>


<!--
Definition of Transaction Manager
-->

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">


<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!--
Base service object
-->


<bean id="Service"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">

<property name="transactionManager">

<ref bean="transactionManager"/>
</property>

<property name="transactionAttributes">
<props>


<prop key="add">PROPAGATION_REQUIRED</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<!-- specifies the methods on which transaction management will be applied-->

</props>
</property>
</bean>

<!--
Children service objects using base service and service
targets
-->


<bean id="UserService" parent="Service">

<property name="target">
<ref bean="UserServiceTarget"/>
</property>

</bean>


<!--
Definition of Action objects
-->


<bean id="userAction"
class=" com.example.user.UserAction" singleton="false">

<constructor-arg>

<ref bean="UserService"/>
</constructor-arg>
<!-- set IUserService in UserAction.java's constructor-->
</bean>

</beans>




syntax highlighted by Code2HTML, v. 0.9.1


10. Last step :) now, write the struts.xml file:


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<package name="user" extends="struts-default">


<action name="SignIn" method="execute" class="userAction" >
<result>/hello.jsp</result>

<result name="error">/login.jsp</result>
</action>
<action name="SignUp" method="signup" class="userAction">

<result>/addUser.jsp</result>
</action>

<action name="add" method="addUser" class="userAction">

<result>/hello.jsp</result>
<result name="error">/addUser.jsp</result>
</action>

</package>

</struts>



syntax highlighted by Code2HTML, v. 0.9.1


------------------------------------------------------------------------------------------------
And here's the validation file, just save it under the same folder as the action.
filename should be <action-classname>-<action-name>-validation.xml
For login action, validation filename would be UserAction-SignIn-validation.xml


<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">


<!--
Validation rules for sign in action
-->

<validators>
<field name="id">
<field-validator type="requiredstring">
<message>You must enter user id</message>

</field-validator>
</field>
</validators>



syntax highlighted by Code2HTML, v. 0.9.1



--
Sheetal

Friday, February 23, 2007

about Latex

Installing latex :

1. download basic miktex from here . ( it's a big file)

2. download and install texnic center . other editors: here.

3. At the very first run of texnic center, u will be asked to provide the latex distribution file. browse and select ur miktex bin folder i.e. if u've installed miktex at mymik folder, then select mymik->miktex->bin).

4. And smileeeeee !! you are done with installing & setting .

Now write your first latex file :

\documentclass{article}
\begin{document}
This is my first document prepared in \LaTeX.
\end{document}


select any of the options Latex->ps , Latex->pdf or Latex->dvi (default option). click build & view button (or press ctrl+shift+F5 ,whatever suits you).

There is another easier way .
  • Create a new project from file menu.
  • Select report /book or whatever suits u from a number of options. In this way most of the usual commands will be auto-written in your document :). Then build & run it as usual.

Here is a help document for typical latex syntex, that may come handy.

5. Including picture using texnic center is very easy.

  • draw anything using xfig or you can also use paint .
  • convert it to *.eps ,
    • if u r using xfig, u can do it with xfig- just click "export" then choose format (.eps or pdf)
    • u can use gimp (thanks to arshad sir)
    • or use adobe photoshop, just save your picture in *.eps format or *.pdf format if you choose Latex->pdf for compilation.
  • Now add the picture by clicking in the picture button .This button will add codes necessary for including picture in your file .
  • If you don't want the image file name to appear in the resulting document , then-
    • save the image in the same folder as the document and
    • use only image name in \includegraphics command (Thanks to nabila for this tip ).
Only thing your have to do yourself is to write an extra line, like the following :

\documentclass{article}
\usepackage{graphicx}
\begin{document}

...

6. For graph plotting ,
  • plot graph using excel.
  • save graph as a picture .
  • add it as a picture (follow step 5).
  • but in this way graph will not be very clear, so i prefer using gnuplot
I don't know whether these steps are going to help u or not. but u can give it a try 'cause it had worked for me .

Last but not the least, here are some other help document1, document 2 for using latex

& good luck with latex :).

Thursday, December 21, 2006

Bhobodoho disaster

plz visit this blog & try ur best to help water locked people of bhobodoho.

u can contribute very easily just by sending an sms.

Send a SMS Message "VOBO" to '2233' from any mobile phone operator in Bangladesh.


This money will aid the students at Bhobodoho to complete their SSC/ HSC exam registration.

This will go on till Jan 20, 2007.

Please send as much SMS as you can. Help the poor students.

Saturday, December 16, 2006

Garden of paradise

well , its our garden :P ,& u may not want to call it a garden though :) .... yesterday i bought some winter flowering plants (marigold , some dahlias) .... and in one of our rose plants this awesome rose bloomed . They all looked so gorgeous and captivating that they literally turned our balcony into the garden of paradise .






& i never knew that i could snap such photos :| .

Friday, December 15, 2006

a story from "the alchemist"

A certain shopkeeper sent his son to learn the secret of happiness from the wisest man in the world. The lad wandered through the desert for forty days and finally came upon a beautiful castle , high atop a mountain . it was there that the wise man lived.

Rather than finding a saintly man, though , our hero , on entering the main room of the castle, saw a hive of activity – tradesman came and went , people were conversing in the corners ,a small orchestra was playing soft music and there was a table covered with platters of the most delicious food in that part of the world . the wise man conversed with everyone , and the boy had to wait for 2 hours before it was his turn.

The wise man listened attentively to the boy’s explanation of why he had come , but told him that he didn’t have time just then to explain . he suggested that the boy look around the palace and return in 2 hours.

“ meanwhile, I want to ask u to do something “,said the wise man , handing the boy a teaspoon that held 2 drops of oil. “as u wander around , carry this spoon with u without allowing the oil to spill.”

The boy began climbing and descending the many stairways of the palace, keeping his eyes fixed on the spoon , after 2 hours, he returned to the room where the wise man was.

“well , did u see the Persian tapestries that are hanging in my dining hall? Did u see the garden that it took the master gardener 10 years to create? Did u notice the beautiful parchments in my library?”

The boy was embarrassed , and confessed that he had observed nothing. His only concern had been not to spill the oil that the wise man had entrusted to him.

“then go back and observe the marvels of my world”, said the wise man . “u cannot trust a man if u don’t know his house.”

Relieved , the boy picked up the spoon and returned to his exploration of the palace, this time observing all of the works of art on the ceilings and walls. He saw the gardens, the mountains all around him , the beauty of the flowers, and the taste with which everything had been selected.

Upon returning to the wise man , he related in detail everything he had seen.

“but where are the drops of oil I entrusted to u ? “ asked the wise man.

Looking down at the spoon he held, the boy saw that the oil was gone.

“well , there is only one piece of advice I can give u.” said the wisest man. “the secret of happiness is to see all the marvels of the world and never to forget the drops of oil on the spoon.”

Thursday, November 23, 2006

The butterfly effect.

For the last couple of days, I kept telling almost everyone the story of butterfly effect at almost aaaaaany context that may (or may not) had had slightest similarity with the movie in one way or another. At last it occurred to me ,why not I write it in my blog ?... so ,here I am :P.

The movie starts with the appearing of a text message about chaos theory ,that goes somehow like “ something as tiny as butterfly's wings might create a tornado.”

What i learned from wikipedia is ,the phrase refers to the idea that a butterfly's wings might create tiny changes in the atmosphere that ultimately cause a tornado to appear (or, for that matter, prevent a tornado from appearing). The flapping wing represents a small change in the initial condition of the system, which causes a chain of events leading to large-scale phenomena. Had the butterfly not flapped its wings, the trajectory of the system might have been vastly different.


Once upon a time (in 2004), there was a boy (our hero ) who one day came to know that his father & grandfather were mad (literally) and had spent most of their life time in mental hospital. & he also used to have some “black-out”s -some moments about which he has no memory. And he did weird things like drawing dreadful pictures ,trying to stab someone in those moments. His worried mom took him to a psychiatrist who advised him to write diary so that he could later remember things happened in that black-out period.

Ok ,after that many things happened ,so I should leave that lowdowns to the potential viewers :P . They (mom & son) moved to big city . He grew up as a very talented person (Ashton Kutcher) who got A in all subjects without even touching books ( don’t ask me how :P),just like his father.

One day while reading his past journals , Ashton found out that he could , physically , go back to past by reading his journal entries of those black-out periods. & not only that he could feel any wound that had happened that time.

Bewildered Ashton searched for his childhood girlfriend to make sure that what he saw was not mere dreaming . He found her as an exhausted depressed waitress who had lost all interest about life because of her freak father who used her in his children porn movies. She committed suicide the next day . That stroke Ashton & he decided to change past to make a better future for that girl.& the real thrill begins from here J

Every time he changed something in past ,that made a huge change in future ,that’s why movie called “the butterfly effect “ , but every future had a biiiiiiig flaw. So to delete that flaw he had to change something else from past & thus create another future with another big flaw .

At last he realized that no matter what you do ,life can never be perfect in all respect.

If u r still reading and haven’t get too bored with my prattling (hence with the movie) ,visit its official site.

ঘিলু নিয়ে ঘাটা ঘাটি

Wednesday, August 30, 2006

check ur reaction

check ur reaction here

all u have to do is to dart the fleeing sheeps among a flock & ur reaction will be calculated according to how fast u can dart them.
& then u'll be rated as any of the 5 category- a (forgot the adjective) chitah,rocketing rabbit,bobbing bobcat,ambling armadillo and sluggish snail.

i was the bobbing bobcat ...:)
enjoy.

Saturday, August 26, 2006

Eyeing the eyes

For the last few days, I’ve been trying to write this story but never find that MOOD to finish & publish it.

It's about a birthday gift from my brother .

If you are the youngest one in the family, you must have the similar story about how everyone else in the family keep treating you as a drooling baby and sometimes even you forget actually how old you are. That's exactly the case with me. I think even in my 50th birthday my mom ( if alive) will still keep fussing about my street-crossing ability (actually I haven’t able to learn that one yet ,:$ .... but, heeeeeee, I can do other things to prove myself adult, huh)

Ok, enough history for today.

My brother's gift was a book, named “Body language” (:P), a footnote on the cover says “know the nature of a person by his expression". My brother chose this because, according to him, I’m still too naïve to see through one’s appearance.

The book is quite an intriguing one, with lots of eye-catching sketches of eyes & lips and other visible body parts, including, of course, what message that part conveys about you.

Today is the “eye –day", lets eye those eyes.



1. if you have this type of eye, you must be
a. very practical,
b. will acquire success in business or politics.
c. You are incredible in love & other intimate relations as you don’t treat others as a good businessman but as a lover :-)




2. You are an artist who is also sincere and credible ( but not in love I guess :-P).



3. if you are a male with this type of eyes, then you are incessantly getting darted by aphrodite’s son (he he :) ) (don’t even dare to give me a black eye, its what the book says ).

But if you are a female …..there is hope :) ….u MAY prove urself as a good life-partner.



4. People having smaller eye-balls than the contour are found to be proudy and wicked .They will do all that caused pain to others.




& i just can't help uploading this pic ....these are shaila's eyes.
those who don't know shaila ,she is my classmate & an almost saint like person (& according to my mom ,a perfect example of a good girl),or i s s h e ?(suspicious music is badly needed here)



5. you are experienced and highly ambitious and u’ll have a life full of true experiences if you are not so yet.




6.women with this eye are chaste but jealous …….but men with this type of eyes are honest ,genuine ,industrious.




7. you are money minded …… you could do everything for money.





8. you favour changes all the time …….anxious, so can’t concentrate on a single topic ……and loooove all the objects of this world except your life partner….[:|]( I was about to say that these are my eyes, but now, you see ...this book has made me reconsider many facts :P)





9.( ahhhhhhh my fingers are making crackling sound ..)...if you are prone to see everything this way, you are the cleverest and apply all possible tricks to solve any issue.



10. you are irrationally emotional.






at last .....about my eyes.....they are really too small to consider ......

buy bangla books online

hello everyone .... bangla books r now available online.Boi-mela is an online bangla book store where more than 5000 books are available over 35 publishers.

They accept all major credit cards.Books are shipped worldwide but shipping method is International Parcel Service of Bangladesh Post Office as its the cheapest among all available options.The shipping cost is determined based on the destination country and total weight including a fixed processing and handling fee on each order (though i think its a bit high,about 250/-).

& the most interesting fact is there are so many books that u've already read.so if u write review / synopsis / story of 50 books ,u'll get a free book (atleast it's said :P).

Sunday, August 13, 2006

struts for beginners

I could never forget those nightmares where I was in front of my pc-
chewing my pen and tearing my valuable hair figuring out a way to run a decent struts program .Groping something for the first time could be so tough sometimes.

That rift in the lute got healed by imran bhaia (he is our teacher now) and rifat. Though I’m tyro enough in struts to advise others …… but, hey ,who’d better understand problems of a novice than another novice [:D] !

This is first document that helped me back then . Hope it may come to rescue u ,too. :)

u can also join sun's jsp forum , believe me its an awesome forum where everyone (& they r expert too) is on his toe even to answer ur most silly and stupidest question ( about struts,ofcourse :P).

Tuesday, July 04, 2006

Professor of Happiness

Offffffffffff ........for me starting something is the most ,what to say , dilemmatic,problematic, hair-tearing situation. Once i start it ,i can finish ... but before starting ,offfffffff ,i spend hours in absolute zombie state ,thinking and ruminating and thinking over.
Is that happen to everyone or just me?

Ok , today's story was about book dedication. its the first thing i read in any book. & its the only thing i consider when i buy a book of any unknown writer. So now here is a sweet dedication that i bumped into -

Our 6 year old son David felt mighty big when he was graduated from Kindergarten. I asked him what he plans to be when he finished growing up. David looked at me intently for a moment and then answered,” Dad , I want to be a professor.”

“A Professor? A professor of what ?” I asked .
“ Well, Dad,” he replied,” I think I want to be a Professor of Happiness.”

A Professor of Happiness ! That’s a pretty wonderful ambition , don’t you think?

To David , then a fine boy with a grand goal , and to his mother , this book is dedicated.