com.jrefinery.report.ext.demo
Class JFreeReportPngServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.jrefinery.report.ext.demo.JFreeReportPngServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, javax.servlet.SingleThreadModel

public class JFreeReportPngServlet
extends javax.servlet.http.HttpServlet
implements javax.servlet.SingleThreadModel

A Sample HttpServlet to show how JFreeReports can be used to generate PNG content in a webbased environment.

The servlet expects a page parameter to be set. This parameter must be greater or equal to one and must fit the report's paginated pages. This servlet is not intended to be a stand-alone solution, it should be used in conjunction with a wrapper page, which uses <IMG> tags to link to this servlet.

POST and GET are handled equal, so it does not matter whether you POST or GET the URL for this servlet.

Author:
Jeevan Sunkersett
See Also:
Serialized Form

Constructor Summary
JFreeReportPngServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the GET method for the servlet.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the POST method for the request.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JFreeReportPngServlet

public JFreeReportPngServlet()
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Handles the GET method for the servlet. The GET method is mapped to the POST method, both commands are handled equal.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - the http request object.
response - the http response object.
Throws:
javax.servlet.ServletException - if an error occured, which could not be handled internaly.
java.io.IOException - if writing the generated contents failed.

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Handles the POST method for the request. This parses the report definition, loads the tablemodel and generates a single page of the report. The generated page is returned as PNG file.

The generated PageStateList is stored in the session so that it can be reused for later calls. The page parameter must be set to a valid value, or the page generation will fail.

The page parameter is required, must be a valid positive integer. The first page is '0'.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - the http request object.
response - the http response object.
Throws:
javax.servlet.ServletException - if an error occured, which could not be handled internaly.
java.io.IOException - if writing the generated contents failed.