aspose file tools*
The moose likes JSP and the fly likes How to display records in Grid view format in Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to display records in Grid view format in Jsp" Watch "How to display records in Grid view format in Jsp" New topic
Author

How to display records in Grid view format in Jsp

Soumya Rout
Ranch Hand

Joined: Aug 06, 2009
Posts: 49

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

Joined: Jan 10, 2002
Posts: 60053
    
  65

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.


  • [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Soumya Rout
    Ranch Hand

    Joined: Aug 06, 2009
    Posts: 49

    Sir thank you very much for reply. Can you please provide me some codes for that.

    krishna Karthikk
    Ranch Hand

    Joined: Mar 16, 2010
    Posts: 92
    Here is the example code, its not MVC architecture, again its a lengthy one, so I am proposing a simple example.


    There is no rule that we all should know everything. Lets learn few things of everything here.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60053
        
      65

    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

    Joined: Jan 10, 2002
    Posts: 60053
        
      65

    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

    Joined: Mar 16, 2010
    Posts: 92
    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

    Joined: Aug 06, 2009
    Posts: 49

    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

    Joined: Jan 10, 2002
    Posts: 60053
        
      65

    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

    Joined: Aug 06, 2009
    Posts: 49

    Soumya Rout
    Ranch Hand

    Joined: Aug 06, 2009
    Posts: 49

    Thank you everyone ..
    I have done It..
    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 9990
        
        7

    Krishna Chaitanya single wrote:

    Please check your private messages for an important administrative matter


    [How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How to display records in Grid view format in Jsp
     
    Similar Threads
    conditional display using <div> in jsp
    Call JFrame From JSP
    Jsp
    Display image in JSP
    Servlet reading a JSP file