i-net Clear Reports

com.inet.report
Class ReportServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.inet.report.ReportServlet
All Implemented Interfaces:
PropertiesChecker, java.io.Serializable, javax.servlet.FilterChain, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
ReportServletJSP

public class ReportServlet
extends javax.servlet.http.HttpServlet
implements PropertiesChecker, javax.servlet.FilterChain

This class implements the communication between the client and the engine, that create the requested report. The ReportServlet reads the parameter from the client, sends it to the engine and sends back the requested page of the report to the client.

The ReportServlet creates a report through the following steps:


1. A client requests the following getLine: http://localhost:9000?report=file:c:/report1.rpt&prompt0=1&SF=true&hasexportbutton=false

2. A properties object is created with contains the pairs (report . http://localhost:9000?report=file:c:/report1.rpt&prompt0=1&SF=true), (prompt0 . 1), (SF . true) (hasexportbutton . false).

3. doWriteHtmlPage() creates a HTML page according to the properties object. You can use the checkHtmlPageProperties() callback and the properties object to modify the HTML code. You can also override doWriteHtmlPage() completely.

4. The viewer starts in the client's HTML page and passes the getLine above back to the report servlet.

5. The report servlet reads the getLine passed to it from the report viewer and converts it into key/value pairs and stores them into a newly allocated properties object. The object contains the entries: (report . http://localhost:9000?report=file:c:/report1.rpt&prompt0=1&SF=true), (prompt0 . 1), (SF . true).

6. doExecRequest() is run and calls the checkProperties() callback which you can use to modify the report parameters. The HttpServletRequest is passed as a second parameter to the checkProperties callback which you can use to implement security.

7. the report template is examined, an engine object is created.

8. The checkProperties() callback with an engine parameter is run. You can use this callback to examine or change the report using RDC. For example you can examine and change the parameter fields, the formulas etc.

9. the report is executed, the report servlet sends back the binary data to the report viewer running in the client's HTML page.

See Also:
Serialized Form

Method Summary
 void afterPropertiesStoredHook(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Properties props)
          Overriding this method is useful only if you want to create a specific target format such as HTML, PDF, etc. and this format should be directly shown in the browser.
 void checkHtmlPageProperties(java.util.Properties props)
          This callback is called before the report server creates and sends back a HTML page with the viewer embedded.
 void checkProperties(java.util.Properties props, java.lang.Object req)
          This callback is called right before the engine examines the report file.
 void checkProperties(java.util.Properties props)
          This method is called by checkProperties(Properties, Object) and is equivalent to checkProperties(props, null).
 void checkProperties(Engine engine, java.util.Properties immutableProperties, java.lang.Object req)
          This callback is called right after the engine has examined the report file.
 void checkProperties(Engine engine, java.util.Properties immutableProperties)
          This method is called by checkProperties(Engine, Properties, Object) and is equivalent to checkProperties(engine, prop, null).
 void destroy()
          Close the log stream and removes the servlet.
 void doExecRequest(java.util.Properties props, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Executes the checkProperties() callbacks and the requested report.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
          Is calling from service method after filtering.
 void doWriteHtmlPage(java.util.Properties props, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          When the browser has sent an initial request, this function calls the checkHtmlPageProperties() callback, creates and sends back an HTML page.
 void init(javax.servlet.ServletConfig config)
          Initialize the servlet and logs the initialization.
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Receive HTTP requests from the client and forward it to the methods that will execute the requested report.
protected  void setPropertiesChecker(PropertiesChecker propchecker)
          Sets a new PropertiesChecker and therefor ignores the previous from Utils or configuration
 

Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialize the servlet and logs the initialization.

Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - servlet configuration information
Throws:
javax.servlet.ServletException - if the servlet cannot be initialized.

destroy

public void destroy()
Close the log stream and removes the servlet.

Overrides:
destroy in class javax.servlet.GenericServlet

doExecRequest

public void doExecRequest(java.util.Properties props,
                          javax.servlet.http.HttpServletRequest req,
                          javax.servlet.http.HttpServletResponse res)
                   throws java.lang.Exception
Executes the checkProperties() callbacks and the requested report. After that it sends back the data of the report to the client.
You can override this method if you want to return the data for the client yourself.

Parameters:
props - The stored properties from the request (report=...&dll=...). Please note that when you override this method, you will find that the props hashtable contains an object which is not a string (the object starts with an underscore). Please ignore this element.
req - The HTTP servlet request
res - The HTTP servlet response
Throws:
java.lang.Exception - IOException if an input or output exception occurred
ReportException can have multiple reasons
See Also:
checkProperties(Properties prop, Object req), checkProperties(Engine engine, Properties prop, Object req)

doWriteHtmlPage

public void doWriteHtmlPage(java.util.Properties props,
                            javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse res)
                     throws java.io.IOException,
                            ReportException,
                            javax.servlet.ServletException
When the browser has sent an initial request, this function calls the checkHtmlPageProperties() callback, creates and sends back an HTML page. You can override this method if you want to return the HTML code for the web-page yourself, in which the report viewer bean is embedded.

Example:
 // here we send back an HTML page with ...
 res.println( "<HTML><HEAD><TITLE> My Report Viewer </TITLE></HEAD>" );
 
 // ... the report viewer applet embedded ...
 res.println( "<applet code=\"com.inet.viewer.ViewerApplet\"" );
 res.println( "codebase=\"http://localhost/client\" id=ReportViewer width=100% height=100%>" );
 res.println( "<param name=ReportName value=\"http://localhost:9000?report=file:c:/report1.rpt\">" );
 res.println( "<param name=Archive value=\"http://localhost/core/ReportViewer.jar\">" );
 res.println( "</applet>" );
 res.println( "</BODY></HTML>" );
 // ... done.
 

Parameters:
props - The stored properties from the request (report=...&dll=...). Please note that when you override this method, you will find that the props hashtable contains an object which is not a string (the object's key name starts with an underscore). Please ignore this element, as it is used internally.
req - The HTTP servlet request
res - The HTTP servlet response
Throws:
java.io.IOException - if there are problems with the streams
ReportException - if checking the properties causes an error
javax.servlet.ServletException - if there are servlet issues with the request or response.
See Also:
checkHtmlPageProperties( Properties prop )

afterPropertiesStoredHook

public void afterPropertiesStoredHook(javax.servlet.http.HttpServletRequest req,
                                      javax.servlet.http.HttpServletResponse res,
                                      java.util.Properties props)
                               throws javax.servlet.ServletException,
                                      java.io.IOException
Overriding this method is useful only if you want to create a specific target format such as HTML, PDF, etc. and this format should be directly shown in the browser. For example if you want to return the report to the client in HTML format, please override this method and after calling super() call props.put("init", "html");

Parameters:
props - The stored properties from the request (report=...&dll=...). Please note that when you override this method, you will find that the props hashtable contains an object which is not a string (the object starts with an underscore). Please ignore this element.
req - The HTTP servlet request
res - The HTTP servlet response
Throws:
java.io.IOException - if an input or output exception occurred
javax.servlet.ServletException - if the servlet cannot handle the request

checkProperties

public void checkProperties(java.util.Properties props,
                            java.lang.Object req)
                     throws ReportException
This callback is called right before the engine examines the report file. The properties object contains the values that the viewer has passed to the report servlet.
If you override this method, you can change or examine the user properties.
Example
if(...) props.put("report", "file:///c:/my-report.rpt");
Please note: The property "report" is initialized with the full qualified report name if the report has been found on the disc (via file:// or file:///context/) or via http://. If not, then the property will contain the original value.

Specified by:
checkProperties in interface PropertiesChecker
Parameters:
props - The user properties. All keys are lowercase.
req - The HTTP servlet request, either null or HttpServlet
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:
PropertiesChecker.checkProperties(Engine engine, Properties prop, Object req)

setPropertiesChecker

protected void setPropertiesChecker(PropertiesChecker propchecker)
Sets a new PropertiesChecker and therefor ignores the previous from Utils or configuration

Parameters:
propchecker - the new PropertiesChecker zu use
Since:
8.1

checkProperties

public void checkProperties(java.util.Properties props)
                     throws ReportException
This method is called by checkProperties(Properties, Object) and is equivalent to checkProperties(props, null).

Parameters:
props - The user properties.
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:
checkProperties(Properties, Object)

checkProperties

public void checkProperties(Engine engine,
                            java.util.Properties immutableProperties,
                            java.lang.Object req)
                     throws ReportException
This callback is called right after the engine has examined the report file. The properties object still contains only the user properties, but you can use the engine API to examine and change the properties red from the report file.
If you override this method, you can change or examine the properties from the report file.

Example:
engine.setSchema(...);
engine.setProperty(...);

Specified by:
checkProperties in interface PropertiesChecker
Parameters:
engine - The initialized engine that have parsed the rpt file already.
immutableProperties - The user properties. All keys are lowercase.
req - The HTTP servlet request, either null or HttpServlet
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:


checkProperties

public void checkProperties(Engine engine,
                            java.util.Properties immutableProperties)
                     throws ReportException
This method is called by checkProperties(Engine, Properties, Object) and is equivalent to checkProperties(engine, prop, null).
This implementation will also initialize the database connections of the report.

Parameters:
engine - The initialized engine that have parsed the rpt file already.
immutableProperties - The user properties.
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker. The ReportException will be send to the client and displayed in the Java viewer.
See Also:
checkProperties(Engine, Properties, Object)

checkHtmlPageProperties

public void checkHtmlPageProperties(java.util.Properties props)
                             throws ReportException
This callback is called before the report server creates and sends back a HTML page with the viewer embedded. The properties object contains the default properties for the HTML page.
If you override this method, you can change or examine the default HTML page properties.

Specified by:
checkHtmlPageProperties in interface PropertiesChecker
Parameters:
props - The properties of the html page. Any change to this properties object itself has absolutely no effect. All keys are lowercase. See Example MyReportServlet_withMyHTMLProperties.java.
Throws:
ReportException - If an error occurred during checking the supplied properties with the current PropertiesChecker.
See Also:
PropertiesChecker.checkProperties(Engine engine, Properties prop, Object req), PropertiesChecker.checkProperties(Properties prop, Object req)

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws javax.servlet.ServletException,
                    java.io.IOException
Receive HTTP requests from the client and forward it to the methods that will execute the requested report.

Overrides:
service in class javax.servlet.http.HttpServlet
Parameters:
req - HttpServletRequest object containing the request
res - HttpServletResponse object containing the response
Throws:
javax.servlet.ServletException - if the servlet cannot handle the request
java.io.IOException - if an input or output exception occurred

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Is calling from service method after filtering.

Parameters:
request - HttpServletRequest object containing the request
response - HttpServletResponse object containing the response
Throws:
javax.servlet.ServletException - if the servlet cannot handle the request
java.io.IOException - if an input or output exception occurred
Since:
11.1
See Also:
service(HttpServletRequest, HttpServletResponse)

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH