• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Jsp tag for creating an HTML table

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Could any one please tell me a jsp tag for creating an HTML table in my jsp ?
Thanks
Maya
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maya,
For a short, simple answer:
You will probably want to use either direct HTML in your page (e.g. <table><tr><td></td><%="some value"%></tr></table>
or output it as part of your internal output structure. (e.g. concat it to some variable - "<TR><TD>The calculated value is <b>" + iSomeVal + "</b></TD></TR>" )
-dane
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add something else to this thread, while outputting lots of HTML code from inside JSP tags is easily achievable, it's not really best practice since you take away the ability for page authors/designers to take away the page and modify the look and feel. In essence, this is for the same reasons behind why JSPs replace(d) Servlets for generating HTML.
With this in mind, given that you need to build a page with tags, there are several ways in which you can minimize the amount of content that custom tags generate. Examples include tags that introduce scripting variables, tags that cooperate on the page, and if you do need to generate HTML, you can use technologies such as CSS to reduce the amount of style information that you put into the page.
Hope that's useful...
Simon
 
Shreya Menon
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the replies.
More specific, I was basically looking for a Tag library which enables be to insert an HTML table in my jsp
something like, ....:table

Can anyone help me ?
Thanks
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the grid tag at http://www.dotjonline.com/taglib/grid.jsp
The look and feel of the grid is customizable using pre-defined CSS styles.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to stick with Simon and say "HTML in tags is evil".
Rather than taking our word for it, it may be a process you have to go through yourself, but it's something I'm dead-set against.
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
I'm going to stick with Simon and say "HTML in tags is evil".
Rather than taking our word for it, it may be a process you have to go through yourself, but it's something I'm dead-set against.


I agree with you and Simon too, but there's something interesting about the future to point out: JSP 2.0, currently in public-draft phase, will support the development of tags using JSP itself. That is, you could generate a reusable whole-table tag by creating a "tag file" expressed in JSP instead of Java.
It might be fun to play with the current RI; I encourage everyone to try it out. The other major feature of JSP 2.0 is the expression language, drawn from JSTL 1.0.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you realy want to do it:
In doEndTag method of Tag:
pageContext.getOut.write("<table><tr><td>....</table>");

In JSP:
<prefix:table />
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic