Thank you all for their responses. Here I am putting part of my coding. Kindly somebody check it and help me to solve my problem.
struts-config.xml
===========
<form-beans>
<form name="bookForm" type="lib.book.BookForm" />
</form-beans>
<global-forwards>
<forward name="home" path="/index.jsp"/>
<forward name="bookHome" path="/books/index.jsp"/>
</global-forwards>
<action-mappings>
<actionpath="/manageBook"
type="lib.book.ManageBook"
name="bookForm"
validate="false"
scope="request"
parameter="action"
input="/books/index.jsp">
<forwardname="success"path="/books/index.jsp"/>
</action>
<actionpath="/saveBook"
type="lib.book.SaveBook"
name="bookForm"
validate="false"
scope="request"
input="/books/index.jsp">
<forwardname="success"path="/books/index.jsp"/>
</action>
</action-mappings>
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
ManageBook.java
================
package lib.book;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.DispatchAction;
import java.util.ArrayList;
public class ManageBook extends DispatchAction
{
public ActionForward view( /* The usual arguments */...) throws Exception
{
String action = request.getParameter("action");
if(action == null) {
action="view";
}
if("view".equalsIgnoreCase(action)) {
/*
*Here I have retrieved all existing books from database and stored in an arraylist
*ArrayList allBooks=new ArrayList();
*/
request.setAttribute("action", action);
request.setAttribute("books", allBooks);
}
/* Here I have removed any FormBean if it is created. */
return mapping.findForward("success");
}
public ActionForward addNew( /* The usual arguments */...) throws Exception
{
String action = request.getParameter("action");
if(action == null) {
action="addNew";
}
if("addNew".equalsIgnoreCase(action)) {
request.setAttribute("action", action);
}
return mapping.findForward("success");
}
}
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
SaveBook.java
================
package lib.book;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class SaveBook extends Action
{
public ActionForward execute( /* The usual arguments */...) throws Exception
{
Book book= new Book();
BookForm bookForm = (BookForm)form;
String action=bookForm.getAction(); /* This I send from the form as a hidden field. */
String target="error";
book.setBookId(bookForm.getBookId());
...
...
...
if("addNew".equalsIgnoreCase(action)) {
target=doSave(request, book);
}
else if("edit".equalsIgnoreCase(action)) {
target=doUpdate(request, book);
}
return mapping.findForward(target);
}
private String doSave(HttpServletRequest request, Book book) throws Exception
{
String target = BookDAO.addBook(getDataSource(request), book);
return target;
}
private String doUpdate(HttpServletRequest request, Book book) throws Exception
{
String target = BookDAO.updateBook(getDataSource(request), book);
return target;
}
}
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/books/index.jsp
===============
...
...
...
<logic:equal name="action" value="view" scope="request">
<template

ut name="content" content="/books/viewBooks.jsp" />
</logic:equal>
<logic:equal name="action" value="addNew" scope="request">
<template

ut name="content" content="/books/addBooks.jsp" />
</logic:equal>
...
...
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/books/addBooks.jsp
===============
...
...
...
<html:form action="saveBook" focus="bookId">
<html:hidden property="action ... ... />
...
...
...
</html:form>
==========================
Thanx in advance.
Niranjan Nanda