There are a lot of components to your question. To Retrieve the data from your db really isn't a struts issue, its done the same as with any other application running on a J2EE server. Set up the datasource on your server and use jdbc to handle your query. There are some other tools out there to help you handle the database transactions but I'm not too familiar with them.
As far as passing the action to the JSP goes, all you need to do is take the data you've retrieved from your DB and store it in properties of your action class (with correctly named getter and setter methods to access it). Once in your JSP you'll just need to specify the name of the property of your action class that you want to display in the the struts2 tag. Take a look at:
I am having the same problem as Sandeep had, I tried to my level best but still i am not able to get the data in the jsp.
But one thing i made possible to fetch single data in jsp, but i am looking for the iteration of all the data from database.
File name is LoginDaoImpl.java
And in JSP file i am writing.
But when i use
I am able to get the single value, but i want all the values of the database thorugh iterator.
I have seperate setter/getter (POJO) class for the Company
Please help me out with the output of database in the JSP page using struts2 way.
You should not need the Java scriptlet. Struts 2 does the work of connecting the JSP with the Action.
If your action has a method getCompanyDetails, the value parameter for the iterator tag should be "companyDetails".
Also, you should do all database queries in the execute method (or whatever you set the action method to be). Should an error occur, you'll want to set an error message or redirect to an error page, and you can't do that in an accessor method.