Putting Java code into a JSP is a discredited and obsolete practice that should have been stopped 14 years ago. 14 years! You are writing code that was considered a bad practice a decade and a half ago. Please learn how to write modern JSP using the JSTL and EL.
Before even thinking about writing a JSP, design the HTML that you need to display the page correctly. Then, and only then, instrument a JSP to create that markup.
Bhagyashri Chaudhari wrote:will you tell me, what is the mistake and requirement in written code?
Mixing Java code inside JSP by using Scriplets is BAD practise. Instead make use of Expression Langauge (EL) i.e process the data in your servlet and store it in request and then access the data in your JSP using EL.
Remember HTTP is a Request/Response protocol. You send a request to a url, you get back the data. That data might be text, it might be image. It is not normally both.
So the way you have it right now, producing the HTML in one request (to the JSP) and in that JSP making image tags with links to the servlet is the right way to do it.
In terms of answering your initial question:
All of the items are appearing in one row.
You make a new row with a <tr> tag.
Obviously your code is not putting the <tr> tag in the right place. How often do you want a new row? Once per database row? Then the <tr> tag should be inside your loop somewhere.
Top tip 1:
If your layout on the page looks wrong, look at the HTML that has been produced by your JSP as a first step, so you can see where it is wrong (in this case the aforementioned lack of additional <tr>s).
That will tell you which bit of your JSP you need to look at.
Top tip 2:
Having a mocked up HTML page to use as a start point for your JSP is handy. You can then structure your JSP tags around the HTML, and see where your loops should be going.