I am developing a web page where on the home page (in my case it is my "Home" servlet) I wish to present information from several tables as well as queries to them. What I have achieved is to obtain the information of my company / brands table and show the last companies added, the detail is that I do not know how to send more than one attribute by the request.setAttribute () as I wish show apart from the information of my table companies also I want to show information in my table users and show my users as well as my table news show the last post (news from suppliers).
I look forward to your help, since I am super stuck with this.
This is my code for my servlet.
public class InicioController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher rd;
//mi conexión a mi base de datos
conexion conn = new conexion();
//le mando el objeto de mi conexión al constructor de mi claseDAO
EmpresaDAO fun = new EmpresaDAO(conn);
List<empresa> lista = new LinkedList<>();
//realizo la llamada al método que obtiene la información de mi tabla empresas
lista=fun.MostrarEmpresa("");
conn.desconectar();
//Aqui es donde quiero mandar mas de un atributo a mi pagina index
request.setAttribute("empresas", lista);
rd = request.getRequestDispatcher("/index.jsp");
rd.forward(request, response);
}
}