package com.yourcompany.struts.model;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
public class InitDataSource implements PlugIn {
private ServletContext servletcontext = null;
public InitDataSource() {
}
public void destroy()
{
servletcontext.removeAttribute("Bookdata");
}
public void init(ActionServlet servlet, ModuleConfig config)
throws ServletException
{
ArrayList<Book> totlebook ;
BookBean bookbean = new BookBean();
try {
totlebook = bookbean.process();
servletcontext = servlet.getServletContext();
servletcontext.setAttribute("Bookdata",totlebook);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
}
}