• 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

Display values form database

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a table with the fields id, name and the content(of the file saved as blob in the database). I want to retrieve them in jsp page and show just id and name in a tabular form.(which i am able to do).

Afetr displaying the values, the I should be able to see the full content when I clicks on the name that has been displayed in the table.

I am attaching the code below.



I want the file to be opened when i click on the below name.

a href="/imageAndDoc/download1.jsp"><%out.println(rs.getString("name"));%></a



Please help.

Thanks,
Madhuri
 
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

JSP is intended for dynamic display purposes and including business logic/application logic is not in conformance with MVC specifications. You ought to move the database manipulation code to a Servlet/Action class.

Steps
1. From the Action/Servlet instance obtain the Connection, fetch the relevant data and pass it in a suitable Collection class to the JSP.
2. In the JSP iterate through the Collection obtained from above and display the data as required.

Cheers,
Raj.
 
Madhuri Abhi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raj,

Thanks for the reply. i haven't followed MVC since i just want to check it. Once i get the solution, I would follow MVC.

What you told is for just displaying the values in jsp from database. What i want to do is something different. Please go thrugh my previous post once again.

I have id, name and conetent fields. I can display id and name (in table) in jsp by having a servlet(action) and DAO(java class). When i click on any of the name displayed, i want its content(i.e the file) to be shown.

How can i do that? Any idea?

Thanks,
Madhuri
 
Rajkamal Pillai
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Madhuri,

Show the Name as a link for each row in the table. On click of the link call the 'Action' to display the detail in a new page alternatively you could also use Javascript to show a new window popup. Pass the parameters in the Query String. You should be able to display them in the popup.

Cheers,
Raj.
reply
    Bookmark Topic Watch Topic
  • New Topic