Rene Ribeiro wrote:It is not loading, it loads only if I make an action on a form.
My servlet's service method with.
To make it more clear, there should be a servlet, In that servlet you should create and populate "listaUf".
You have to set that in a request attribute.
Then control goes to JSP and you will have your values there to iterate.
Rene Ribeiro wrote:I need my JSP load the UFs in servlet.
So I am getting confused here by the above statement.
JSP does not load objects in servlet.
In your case servlet should get all the data from DAO you want to display in front end.
Those data should be passed to JSP and formatted accordingly for display.
BTW few things about the code.
You have used ClienteDAO class in servlet, but did not post the code of that class.
You have posted the code of UfDao class, but never used that in servlet.
Avoid creating public member variables in class. Member variables SHOULD always be private.
Release the SQL objects in finally block, otherwise they will cause the database to throw exceptions after maximum connections/cursors are used.
Servlets have doGet() and doPost() methods. Use them.
posted 2 years ago
I'm not using doPost or doGet because they are not being submitted but only loaded without user interaction. To use the doPost or doGet I need is coming from a form.
As I need to fill a ComboBox, as you would using this list?
Rene Ribeiro wrote:I'm not using doPost or doGet because they are not being submitted but only loaded without user interaction. To use the doPost or doGet I need is coming from a form.
There is no need to do all these.
You pass all the required data when you are going to JSP from Servlet for the very first time (Are you going to the JSP from a Servlet?)
You do an AJAX call from the JSP and fetch required data without submitting the form.