Hi, I am in project where i have to search from database and display them in a tabular manner like in GridView.
Please anybody tell me how to do it jsp.
I have no idea what a GridView is -- it's certainly not a JSP concept.
Here's how I would do it:
The page controller would call a business-layer class to fetch the information.
In the business-layer class, I'd get the data from the database and copy it from the resultset into a Java collection and close the resultset as soon as possible. If appropriate I'd use a java.util.List of beans that represent the items to be displayed. Or it could be as simple as Object[][]
The list (or array) would be returned to the controller, which would set it as a scoped variable in request scope.
The controller would forward to the JSP.
In the JSP, the <c:forEach> tag, perhaps nested if necessary, would iterate over the List or array to create the HTML table markup to display the data.
Bear Bibeault wrote:Good grief! Scriptlets in a JSP? SQL in a JSP? What is this, 1999?
Definitely not the example to follow.
Yes Bear, you are right, thats what I said before itself, I just proposed her an example, I already declared its not MVC architecture and its not using the standards of now a day.
There is no rule that we all should know everything. Lets learn few things of everything here.
And when i try to retrieve the "data" in jsp Page by the request.getAttribute("data"); method its showing nothing.
And i tried to display data whether data is coming to the Arrylist or not and written out.println(data);
It showed an infinity nos of some Arrylist[uiwy]j (something .. something ) in the browser ..