Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Joe Ess wrote:What does the createBook method look like? It should have the same signature as the execute method, coderanch, String return value and no arguments.
titli das wrote:ACTION CLASS:
package library;
import java.util.*;
import java.io.*;
public class Book {
private String bookName;
private String author;
private int seqNo;
public static List<Book> li = new ArrayList<Book>() ;
public Book()
{
;
}
public Book(String bookname, String author, int seqNo)
{
this.bookName = bookname;
this.author = author;
this.seqNo = seqNo;
}
public String getBookName()
{
return bookName;
}
public String getAuthor()
{
return author;
}
public int getSeqNo()
{
return seqNo;
}
public void setBookName(String bookName)
{
this.bookName = bookName ;
}
public void setAuthor(String author)
{
this.author = author ;
}
public void setSeqNo(int seqNo)
{
this.seqNo = seqNo ;
}
public String createBook()
{
if(bookName != null)
{
li.add(this);
}
System.out.println("Book Entry Created");
for(ListIterator<Book> it_2 = li.listIterator();it_2.hasNext();)
{
Book bookPrint = (Book)it_2.next();
System.out.println(bookPrint.getBookName() + " " + bookPrint.getAuthor() + " " + bookPrint.getSeqNo());
}
return "SUCCESS";
}
public String execute()
{
return "SUCCESS";
}
}
struts.xml:
<struts>
<constant name = "sruts.devMode" value = "true" ></constant>
<package name = "default" extends = "struts-default">
<action name = "LibraryLogin" class="library.login">
<result name = "SUCCESS">/home.jsp</result>
<result name = "FAIL">/login.jsp</result>
</action>
<action name = "CreateBookEntry" method = "createBook" class="library.Book" >
<result name = "SUCCESS">/createBookEntry.jsp</result>
</action>
<action name = "test" class="library.Book" >
<result name = "SUCCESS">/createBookEntry.jsp</result>
</action>
</package>
</struts>
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |