Printing to a label printer from a web-based Java application

We have a Java-based web application, using Apache Tomcat as the server.  We want to be able to print to label printers using various sizes of label stock (significantly smaller than legal, letter, etc.).  

Additionally, because this is a label and not a whole document, we want the browser to ignore its header and footer settings.

Has anyone accomplished this, or heard of anyone who has?

When we print to our sample printer (a Brother P-touch QL500), one of two things happens:
If in Portrait mode, get one label with the browser's defined header and footer.
If in Landscape mode, get enough labels to make an 8.5" wide piece of paper (Page 1 of 27 and so on...)

Thank you.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can create a separate css for printing and set the layer to hidden when printing.

#header, #footer {
  display: none;

    <input:stylesheet href="/print_style.css" media="print"/>
<div id="header">Put header here</div>

<div id="label">Put label here</div>

<div id="footer">Put footer here</div>

A better way is to use JasperReports to design the label and export it to pdf file or JasperReport applet for printing, this will ensure you get the exact size and format you want.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The information you want to change are browser settings. These cannot be controlled throught the web page. You'll find the settings for margins, headers and footers under file-page setup. In IE you'll also find a list of paper types and sizes there including "user defined," but I'm not sure how you define the size.
I should mention there are two different types of headers: those create with <h1> thourgh <h6> and those added by the browser adding url, date, etc to the page. The later type are controlled by the user through Page Setup. The former would be controlled through a style sheet as Boonleng suggests.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

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.