This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Building HTML

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to create an HTML table from an array, apply loads of formatting and so on to it, and then output it in a JSP. I was going to do it all from scratch, and then I thought I could start off using XML instead to save myself some work, and then I found there were a whole load of standard HTMLElement etc classes too. But I just don't get how to use them in practice, and it seems hard to find any step-by-step tutorials for newbies!

Can anyone give me a few hints?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would bind the array to one of the scoped objects, forward to a JSP, and then build the HTML by iterating over the array with JSTL.
 
Richard Hooper
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing is, I've got an existing application where the same JSP is used to output all manner of different reports, and they've only just realised that they want some specific formatting on some of bits. I don't want to have to have multiple JSPs if I can help it, and I don't want to fill the JSP with logic to work out how to display everything in all cases - that's why I want to do all the heavy lifting at the servlet end. I just can't get my head around using the XML API, even though it seems to be just the thing!

I may end up doing it some other way in the end, of course!
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the FormattedDataSet at www.fdsapi.com (one of my open source projects). It can create dynamic text (html, xml, and more) from tabular data (ResultSets, arrays and more). You can point the same data at different formatting templates. The API comes with a few default templates (xml, html table and a few others), and you can easily create more.

Here is how the code would work:


It is simple and fast. There is a live demo at the sight that creates dynamic content. If you have any questions let me know.
[ January 30, 2006: Message edited by: steve souza ]
 
Richard Hooper
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll have a fiddle, looks good! Cheers!
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic