Hi, I am just starting out to code using Struts framework and i cant move any further because of this error. here's my xml files :
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"
<!--
This is the Struts configuration file for the example application,
using the proposed new syntax.
-->
<struts-config>
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>
<!-- bookForm -->
<form-bean name="bookForm" type="books.Book"/>
</form-beans>
<!-- ========== Global Forward Definitions ============================== -->
<global-forwards>
<!-- bookForm -->
<forward name="bookCreated" path="/BookView.jsp"/>
</global-forwards>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<!-- bookForm -->
<action path="/createBook"
type="books.BookAction"
name="bookForm"
scope="request"
input="/CreateBook.jsp">
</action>
</action-mappings>
<!-- ========== Controller Configuration ================================ -->
<controller>
<!-- The "input" parameter on "action" elements is the name of a
local or global "forward" rather than a module-relative path -->
<set-property property="inputForward" value="true"/>
</controller>
<!-- ========== Plug Ins Configuration ================================== -->
<plug-in className="org.apache.struts.plugins.ModuleConfigVerifier"/>
<plug-in className="org.apache.struts.webapp.example.memory.MemoryDatabasePlugIn">
<set-property property="pathname" value="/WEB-INF/database.xml"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"
<web-app>
<display-name>Struts Example Application</display-name>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- Application Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/app.tld</taglib-uri>
<taglib-location>/WEB-INF/app.tld</taglib-location>
</taglib>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>
CreateBook.jsp
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<html:base/>
<title><bean:message key="index.title"/></title>
</head>
<body bgcolor="white">
<h2>Create a book</h2>
<html:errors/>
<html:form action="createBook.do" method="GET">
Title:<html:text property="title" /> <br/>
<html:submit property="submit"/>
</html:form>
</body>
</html:html>
BookAction.java
package books;
import javax.servlet.http.*;
import org.apache.struts.action.*;
/*
The action for the creation of a book.
@author stephan@stephanwiesner.de
*/
public final class BookAction extends Action
{
/**
@param mapping The ActionMapping used to select this instance
@param form The optional ActionForm bean for this request (if any)
@param req The non-HTTP request we are processing
@param res The non-HTTP response we are creating
@return Return an ActionForward instance describing where and how
control should be forwarded, or null if the response has already
been completed.
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
try{//xxpmnomr
System.out.println("Start perform(" + form + " . . ." );
String title = req.getParameter("title"
Book book = new Book();
book.setTitle( title );
System.out.println("After creation of book: " + book.getTitle() );
req.setAttribute("BOOK", book);
return mapping.findForward("bookCreated"
}catch(Exception e){
System.out.println("ERROR HERE"
return mapping.findForward("bookCreated"
}
}
}
Book.java
/*
* Created on Oct 17, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package books;
/**
* @author xxpmnomr
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
import java.util.Vector;
public class Book {
/*
A simple book.
@author stephan@stephanwiesner.de
*/
/** The title */
private String title = "";
/** We can have more than one author */
private Vector authors = new Vector();
/** The number of pages the book has */
private int pages = 0;
/** Standard constructor. */
public Book()
{ }
/** @param title The new Title */
public void setTitle(String title)
{ this.title = title; }
/** @return The title. */
public String getTitle()
{ return this.title; }
/** @param pages The new number of pages. */
public void setPages(int pages)
{ this.pages = pages; }
/** @return The number of pages. */
public int getPages()
{ return this.pages; }
/**
We don't want to work with the Vector here, as it is
only a reference we would get!
@param author Add another author
*/
public void addAuthor(String author)
{ this.authors.add(author); }
/**
Pay attention not to use the wrong number.
@param position The number of the author to remove.
*/
public void removeAuthor(int position)
{ this.authors.remove(position); }
/** @return The number of authors the book has. */
public int getNumberOfAuthors()
{ return this.authors.size(); }
}
Any help would be appreciated.
Thanks!
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"
<!--
This is the Struts configuration file for the example application,
using the proposed new syntax.
-->
<struts-config>
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>
<!-- bookForm -->
<form-bean name="bookForm" type="books.Book"/>
</form-beans>
<!-- ========== Global Forward Definitions ============================== -->
<global-forwards>
<!-- bookForm -->
<forward name="bookCreated" path="/BookView.jsp"/>
</global-forwards>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<!-- bookForm -->
<action path="/createBook"
type="books.BookAction"
name="bookForm"
scope="request"
input="/CreateBook.jsp">
</action>
</action-mappings>
<!-- ========== Controller Configuration ================================ -->
<controller>
<!-- The "input" parameter on "action" elements is the name of a
local or global "forward" rather than a module-relative path -->
<set-property property="inputForward" value="true"/>
</controller>
<!-- ========== Plug Ins Configuration ================================== -->
<plug-in className="org.apache.struts.plugins.ModuleConfigVerifier"/>
<plug-in className="org.apache.struts.webapp.example.memory.MemoryDatabasePlugIn">
<set-property property="pathname" value="/WEB-INF/database.xml"/>
</plug-in>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"
<web-app>
<display-name>Struts Example Application</display-name>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- Application Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/app.tld</taglib-uri>
<taglib-location>/WEB-INF/app.tld</taglib-location>
</taglib>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>
CreateBook.jsp
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<html:base/>
<title><bean:message key="index.title"/></title>
</head>
<body bgcolor="white">
<h2>Create a book</h2>
<html:errors/>
<html:form action="createBook.do" method="GET">
Title:<html:text property="title" /> <br/>
<html:submit property="submit"/>
</html:form>
</body>
</html:html>
BookAction.java
package books;
import javax.servlet.http.*;
import org.apache.struts.action.*;
/*
The action for the creation of a book.
@author stephan@stephanwiesner.de
*/
public final class BookAction extends Action
{
/**
@param mapping The ActionMapping used to select this instance
@param form The optional ActionForm bean for this request (if any)
@param req The non-HTTP request we are processing
@param res The non-HTTP response we are creating
@return Return an ActionForward instance describing where and how
control should be forwarded, or null if the response has already
been completed.
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
try{//xxpmnomr
System.out.println("Start perform(" + form + " . . ." );
String title = req.getParameter("title"
Book book = new Book();
book.setTitle( title );
System.out.println("After creation of book: " + book.getTitle() );
req.setAttribute("BOOK", book);
return mapping.findForward("bookCreated"
}catch(Exception e){
System.out.println("ERROR HERE"
return mapping.findForward("bookCreated"
}
}
}
Book.java
/*
* Created on Oct 17, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package books;
/**
* @author xxpmnomr
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
import java.util.Vector;
public class Book {
/*
A simple book.
@author stephan@stephanwiesner.de
*/
/** The title */
private String title = "";
/** We can have more than one author */
private Vector authors = new Vector();
/** The number of pages the book has */
private int pages = 0;
/** Standard constructor. */
public Book()
{ }
/** @param title The new Title */
public void setTitle(String title)
{ this.title = title; }
/** @return The title. */
public String getTitle()
{ return this.title; }
/** @param pages The new number of pages. */
public void setPages(int pages)
{ this.pages = pages; }
/** @return The number of pages. */
public int getPages()
{ return this.pages; }
/**
We don't want to work with the Vector here, as it is
only a reference we would get!
@param author Add another author
*/
public void addAuthor(String author)
{ this.authors.add(author); }
/**
Pay attention not to use the wrong number.
@param position The number of the author to remove.
*/
public void removeAuthor(int position)
{ this.authors.remove(position); }
/** @return The number of authors the book has. */
public int getNumberOfAuthors()
{ return this.authors.size(); }
}
Any help would be appreciated.
Thanks!