Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes Printing contents Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Printing contents" Watch "Printing contents" New topic
Author

Printing contents

Shailesh Pillai
Ranch Hand

Joined: Jan 24, 2006
Posts: 78
Hello Ranchers,

Can anyone suggest me how to print the contents i have on my jsp page to a printer.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

On the client or the server?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shailesh Pillai
Ranch Hand

Joined: Jan 24, 2006
Posts: 78
Both, on the client as well as on the server.
GS Chidam
Ranch Hand

Joined: Jul 07, 2006
Posts: 34
hi,

If your jsp page contain the data, just export to excel using jxl.write,
Class WritableWorkbook, then print.

What is your jsp contain? How you want to print?
Shailesh Pillai
Ranch Hand

Joined: Jan 24, 2006
Posts: 78
My jsp displays data(from database) in a tabular format. In my jsp page, I do have some headings and other stuff, but i only want the data in tabular format to be printed.

How about the PrinterJob class?
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Use JasperReports with iReport.


My blood is tested +ve for Java.
GS Chidam
Ranch Hand

Joined: Jul 07, 2006
Posts: 34
using jxl.write, just export to excel then print.

Already you are having jsp display data in the List isn't, use that data, Export to excel.

The example code something like this.


response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=dfs.xls");
WritableWorkbook w = Workbook.createWorkbook(response.getOutputStream());

WritableSheet s = w.createSheet("sheet name", 0);

WritableFont wfTitle = new WritableFont(
WritableFont.ARIAL, 14);
Label l1;

WritableCellFormat cfTitle = new WritableCellFormat(wfTitle);
l1= new Label(0,0,"abc",cfTitle);
s.addCell(l1);
Shailesh Pillai
Ranch Hand

Joined: Jan 24, 2006
Posts: 78
Thanks all for your reply.
 
 
subject: Printing contents
 
Similar Threads
Mr.Kyte, could you introduce a little about your book?
Book Content
asp
Book Promo: does it have a table of contents?
Silk test 8 doesnt recognizes objects in firefox 2