File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to get the printer friendly version of a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to get the printer friendly version of a JSP" Watch "How to get the printer friendly version of a JSP" New topic
Author

How to get the printer friendly version of a JSP

Srini Nivas
Greenhorn

Joined: Aug 25, 2005
Posts: 21
I am generating a JSP that contains dynamic data in tables. The tables can be sorted. Now I what to have a link that displays the printer friendly version of that sorted data. How can I do this?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

It is up to you. First, decide what is printer-unfriendly about how your current page looks. Next, make a new design that looks better on the printer. Write a new JSP to produce that design and provide a link to that JSP. (And finally, throw away the original JSP and just use the new and improved one.)

The only time I have seen "printer-friendly" on web pages is where the normal version is text (like a magazine article) divided into several linked pages covered with advertising and the printer-friendly version has all the text on a single page. Does that describe your situation?

It's also possible to use CSS in such a way that irrelevant parts of your JSP's output, like a column of links or "delete" checkboxes for example, do not appear in printed versions of the output.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

For more information about doing this with CSS :
Going to print


[My Blog]
All roads lead to JavaRanch
Srini Nivas
Greenhorn

Joined: Aug 25, 2005
Posts: 21
Thanks....I will try writing a new JSP......I have to remove the header and some gif's from my original JSP, also the sortable links in the tables for my printer friendly version. I am not sure how to use style sheets for that.....!!!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Originally posted by Srini Nivas:
Thanks....I will try writing a new JSP......I have to remove the header and some gif's from my original JSP, also the sortable links in the tables for my printer friendly version. I am not sure how to use style sheets for that.....!!!
If that's all you want to do then I think you should definitely use the CSS method. If your HTML is littered with <font> tags and other layout controls, then you should really rewrite it to use CSS anyway. Here's the piece of my CSS that controls the print format:This says that elements like <TH class="links"> etc. will not appear in printed versions of the page. But follow the link that Satou provided (and links from that page as well) for details.
Srini Nivas
Greenhorn

Joined: Aug 25, 2005
Posts: 21
I didnt quite get it! Can u give me some sample code???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Discussion of CSS is best handled in the HTML forum, so this has moved there.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Consider Paul's rocket mass heater.
 
subject: How to get the printer friendly version of a JSP