jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes take print out of jsp page without default header 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 "take print out of jsp page without default header" Watch "take print out of jsp page without default header" New topic
Author

take print out of jsp page without default header

simran chandwani
Greenhorn

Joined: Jun 29, 2009
Posts: 2
Hello,
I need to take print out of jsp page. I am using window.print() of javascript. It prints page with default header & footer . I need take print outs without header & footer . Can anybody suggest me.

Thanks in adv

Simran Chandwani
Keerthi Sagar
Greenhorn

Joined: Apr 21, 2007
Posts: 28
Hi Simran,
Check the following steps;
=> Write the whole content in a div tag
=> Open a popup window write the contents into that window
=> Print the popup window
=> Close the popup window.

Sample javascript function will be like;
function CallPrint(){
var printContent = document.getElementById("txtDiv");
var Win4Print = window.open('','','left=0,top=0,width=500,height=500,top=301,left=365,resizable=1,status=0,toolbar=0');
Win4Print.document.write(printContent.innerHTML);
Win4Print.document.close();
Win4Print.focus();
Win4Print.print();
Win4Print.close();
}

Regards,
Y. Keerthi Sagar.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Default Header and Footer = the date, timestamp, url, title?

The answer is, not possible without hacking your user's computer

If it is your header and footer, CSS Print Media is your answer, no need for pop up windows.

Eric
jyoti sarangi
Greenhorn

Joined: Nov 03, 2009
Posts: 1
i have little bit different situation ... i need all the pages to contain header and footer...... for some record if am taking the print out then its coming in one page if data is small....but in some cases my jsp is going for 4 pagees....... in that situation header is coming in the first page and footer is coming in the last page........can it possible to do something which will set the header and footer for all the pages.......???///

regards,
JytoiShankar
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: take print out of jsp page without default header