Dear Sirs, Apologies for the length of this post but I have read forums, book and websites and cannot find how to do this. I'm sure it is very simpe but I am a complete novice so any help would be much appreciated.
I am new to struts and have hit a road block concerning action mappings. >From everything that I have read the action class gets called in the event of a form being submitted for example. However, I do not want any form to be processed, just when the jsp page is accessed the action class is called. Hi current am using a struts datasource and a data access object. When a jsp page is accessed I want to be able to store the rows of the database in an array and iterate them back out to the jsp page. The Action class can be found below package com.myapp.struts; import javax.servlet.http.*; import org.apache.struts.action.*; import java.sql.*; import java.util.ArrayList; import javax.sql.*; public class DataSourceConnectionAction extends Action { private DataSource dataSource; public ArrayList court1List = new ArrayList(); private final static String SUCCESS = "success"; public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); /** Here the method that connects to the datasource is called: */ dataSource = (DataSource)servlet.getServletContext().getAttribute("SportsHall"); Connection conn = dataSource.getConnection(); UserDAO dao = DAOFactory.createUserDAO(conn); court1List = dao.getCourt1(); /** Here we put the court1List in scope, so that we can use it in the JSP page: */ if(court1List != null){ request.setAttribute("SportsHall", court1List); } return (mapping.findForward(SUCCESS)); } } The jsp page then contains this: <% java.util.ArrayList court1List=(java.util.ArrayList) session.getAttribute("sports_hall_1"); %> <logic:notPresent scope="request" name="SportsHall"><h2>Data source not in scope!</h2></logic:notPresent> <logic:present name = "SportsHall"> <logic:empty name = "SportsHall"> <h2>Data source in scope but no data found!</h2> </logic:empty> </logic:present> <logic:present name = "SportsHall"> The logic not present tag always shows that there is nothing there. Is this because there is not an appropriate action mapping? I used the tutorial under the section Working with a Struts Data Source: A Simple Scenario with the only exception of changing the datasource to my personal MySQL datasource, tutorial can be found here: http://www.netbeans.org/kb/50/tutorial-webapps-struts.html hence, I have a class called row with the getter and setter methods in. Following this tutorial seemed appropriate as it was exactly what i needed to do with the exception of not having a form to sumbit and I am using Netbeans. I have the same setup as the tutorial with the classes: UserDAO row DAOFactory MySQLUserDAO DataSourceConnection Action (As shown in the original post) Apologies but could you instruct for a complete begginer? Many thanks for your help in advance, this is a big learning curve for me. Regards Mike -- View this message in context: http://www.nabble.com/Struts-HELP---DAO%2C-Datasource-and-Displaying-Data-tf2880501.html#a8048995 Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]