• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to display records in Grid view format in Jsp

 
Ranch Hand
Posts: 49
Netbeans IDE Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Netbeans IDE Java ME Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Sir thank you very much for reply. Can you please provide me some codes for that.

     
    Ranch Hand
    Posts: 92
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Netbeans IDE Java ME Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Netbeans IDE Java ME Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
     
    Soumya Rout
    Ranch Hand
    Posts: 49
    Netbeans IDE Java ME Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you everyone ..
    I have done It..
     
    Bartender
    Posts: 11497
    19
    Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Krishna Chaitanya single wrote:


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