jsp and htnl table Design

Posted on 2004-08-18
Medium Priority
Last Modified: 2013-12-03
I am currently writing a web application using jsp. The aim of the system is to price
items of work. I wont go too indepth as to what it does but I have jsp pages that
produce a sumary of prices and descriptions of each item of work(from database)
in html table format. As a requirement I need to be able to print this information from
Internet Explorer. I have been stuck on this for quite some time and i need some expert advise
as to how i would organise the dynamic content of my jsps to produce html tables that can be printed.
Eg.. if there are 400 items of works to be printed this will take perhaps 20 A4 printed pages, each row in the html table may be of different height, depending on the information regarding that item.
Is it possible that each page will contain the table heading;;
(simplified example..)
also is it possible to avoid table row entries being split horizontaly over 2 pages.
Thanks in Advance..
Question by:adriankelly
  • 5
  • 3
  • 2
  • +2
LVL 11

Expert Comment

ID: 11832039
if you want to split like this, I think it's possible by using programming.

1                     8
2                     9
3                     10
4                     11
5                     12
6                     13
7                     14

if you want to do like this, it's very quite difficult becuase we will not know how much row will fit to one page
but if you really want to do this you may provide textbox in the prior page for who want to print can configure
how many rows per page.

1                     4
2                     5
3                     6

7                     10
8                     11
9                     12


Hope this can generate your idea.


Author Comment

ID: 11832165
The table will look like

quanty |  price  | description| tax    |.....Top of table
2         |12.0    | a product  |  12% |    .....Typical table row
3         |11.0    | a product   |14% |   ...... A row with increased height
           |          |that needs  |
           |          | alot more   |
           |          |description  |  
LVL 11

Expert Comment

ID: 11832263
the height of each row will depend on data its reside. but you have fix the width of column by

  <td width="30">
  <td width="50">

The above code will fix width of first column to 30 pixel and the second 50 pixel
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

LVL 11

Expert Comment

ID: 11832287
about the table header that you want to print in every page. like I said you may ask client user to submit the number of row to print per page. so we can print the header again when the row reach the value they submit.

Author Comment

ID: 11832479
Imagine you have a web page with a html table with 400 rows in it. Each row is of varying tickness/ height. I need to print this table so that each printed page will have the table heading on it and no rows of the table will be split across 2 of the printed A4 paper pages
LVL 11

Expert Comment

ID: 11832881
Umm. I see. So in case of the last row on that page, if that whole row can fit into the page so how can we push that row to the next page and also re-print the header of the table, right?

this comment just clarify your question. I will try to find solution for you


Expert Comment

ID: 11833183
I think you may want a CSS printing style sheet. I am not familiar with the details of how to do it but I think it may be the solution to your problem.

Author Comment

ID: 11839156
Sompol has got what im trying to do.
Iv tried some CSS stuff but havent had much success. I am reasonably new to web design and felt that this problem would have been encountered before.
There has to be a way around it!
Could I take the info from my java classes and show the information on some
type of scrollable  applet as opposed to html??
I really need to get it sorted.  

Expert Comment

ID: 11846284
This would be a different direction for you, but if the report needs to be printed, you should consider PDF generation.  PDF by design was made for this type of a thing whereas HTML by design was not.  There are plenty of free and/or inexpensive libraries to use for generating PDFs.  If you can find one that can provide you with some kind of feedback as to how much space you have left on a particular page as you are generating it, then you've found waht you need.

Accepted Solution

jjerome00 earned 375 total points
ID: 11853396
HTML wasn't designed to have these features, but you can certainly cheat to get the results you want.  I would take a look at the data you are trying to display, and see how often these multiple lines of description usually are.  

First I would find out how many physical table rows fit on a page.  By physical rows I mean an actual line of text (i.e. one item might produce more than one physical row - your example above has 9 rows).

I would then keep track of how many of these physical rows have been used on the page.  Since you can set the width of the columns, you can calculate how many letters constitute a new row.  For example, the description field in your example might have 100 characters, and you know you can fit 20 characters per row - you have 5 rows for that one item.  The idea is to keep a relatively good idea of how many rows you are displaying.

When you get to the maximum number of rows for the page, then you can close out the table, add some space to get to the next page, and restart a new table.

Of course you will have to play around with your settings a bit, but you should be able to build a few functions to break down the problem into smaller tasks.  You can calculate how many rows an item entry should take and see if it will fit on the page, or if it should start on the next page.

Good luck!


Expert Comment

ID: 11853476
If you decide by chance to look at the PDF route, there is a product called pd4ml.  It is fairly inexpensive (approx $75 US per site or program you use it in) and even free if what you're doing is non-profit.  It converts HTML output to PDF, so if you can manage to get your HTML to format just the way you want you only have to worry about how it fits in one environment instead of making it work for every browser on the planet and every printer configuration that they have.
LVL 11

Expert Comment

ID: 11866647
If you want to use reporting tools for free, I recommend jasper.


best luck,

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Sometimes when I'm using my iPad, one of my apps will start acting weird or it just stops working. After reading articles and finding solutions on my own, I decided to share solutions I have found helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question