aspose file tools*
The moose likes JSP and the fly likes Page Number on JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Page Number on JSP" Watch "Page Number on JSP" New topic
Author

Page Number on JSP

Terence Chan
Greenhorn

Joined: Nov 29, 2005
Posts: 4
Dear All,

I am trying to display page number on a jsp for a report task. Can any help?

PS
I know I can let IE do the page number display but is there any other way of doing it?
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
The page number in IE, and Mozillla is an artifact of when the browser paginates the screen to fit onto paper when printing it.

If you have a report output and a JSP is rendering it as a long list on one page, you could have the logic that prints out the table in the JSP page to break up the table within the output, so that you can calculate the page number and display it.

for example,


Error: Keyboard not attached. Press F1 to continue.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You have no way, on the server, of knowing how the browser is going to paginate your HTML output when it prints it. The user can direct the browser to change font size, to print in landscape instead of portrait mode, and so on. If you want to control the pagination then HTML is not the right tool. PDF would work better for that.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

There are ways of estimating it (MapQuest does a decent job at this) so you might be able to get close for practical purposes, but it'll never be precise. The best way, as previously mentioned, is to use PDF/PS exports.


My Blog: Down Home Country Coding with Scott Selikoff
Terence Chan
Greenhorn

Joined: Nov 29, 2005
Posts: 4
Dear Travis, Paul, and Scott

First of all, thanks for all of your replies. Moreover, I am very interested in learning more on Travis sugguestion (Since I don't want to rewrite my whole program using pdf)! Appriecate if travis could give me detail (A complete example) on the solution.

Terence
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I guess using a third-party open source report frameworks is your best bet.
Like JasperReports, or JFreeReports
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Page Number on JSP