Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display records in Grid view format in Jsp

 
Soumya Rout
Ranch Hand
Posts: 49
Java Java ME Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  •  
    Soumya Rout
    Ranch Hand
    Posts: 49
    Java Java ME Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Sir thank you very much for reply. Can you please provide me some codes for that.

     
    krishna Karthikk
    Ranch Hand
    Posts: 92
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Here is the example code, its not MVC architecture, again its a lengthy one, so I am proposing a simple example.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64683
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Good grief! Scriptlets in a JSP? SQL in a JSP? What is this, 1999?

    Definitely not the example to follow.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64683
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Soumya Rout wrote:Sir thank you very much for reply. Can you please provide me some codes for that.

    Please read NotACodeMill.

    Besides, that's all really simple stuff. What part do you think you'll have problems with?
     
    krishna Karthikk
    Ranch Hand
    Posts: 92
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Soumya Rout
    Ranch Hand
    Posts: 49
    Java Java ME Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    My servlet is like this :-








    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 ..

    Please help me out.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64683
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Where do you copy the result set to a List or array?

    Where are you creating a scoped variable named "data"?

    Your code doesn't even forward to a JSP.
     
    Soumya Rout
    Ranch Hand
    Posts: 49
    Java Java ME Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
     
    Soumya Rout
    Ranch Hand
    Posts: 49
    Java Java ME Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you everyone ..
    I have done It..
     
    Maneesh Godbole
    Saloon Keeper
    Posts: 11021
    12
    Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Krishna Chaitanya single wrote:

    Please check your private messages for an important administrative matter
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic