Package com.inet.report
Class ReportServletJSP
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- com.inet.report.servlets.ReportPluginServlet
-
- com.inet.report.ReportServletJSP
-
- All Implemented Interfaces:
com.inet.http.PluginServlet
,java.io.Serializable
,javax.servlet.jsp.HttpJspPage
,javax.servlet.jsp.JspPage
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public abstract class ReportServletJSP extends com.inet.report.servlets.ReportPluginServlet implements javax.servlet.jsp.HttpJspPage
This class implements the communication between the client that created the requested report and the engine. The ReportServletJSP is meant to be used as a parent for JSP pages which want to make use of i-net Clear Reports. It implements a method that reads parameters from the request and stores them in the variableprops
. The descending JSP servlet can read these parameters and create a HTML page.
Here's how a JSP is used to generate a report:- A client requests the following getLine: http://localhost:8080?report=file:c:/report1.rpt&prompt0=1&SF=true&hasgrouptree=false
- A properties object is created with contains the pairs (report . http://localhost:8080?report=file:c:/report1.rpt&prompt0=1&SF=true), (prompt0 . 1), (SF . true) (hasgrouptree . false).
- The code below marked with "STEP 1" is returned to the client. You can use the properties object to modify the HTML code.
- The viewer starts in the client's HTML page and passes the getLine above back to the report servlet.
- 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:8080?report=file:c:/report1.rpt&prompt0=1&SF=true), (prompt0 . 1), (SF . true).
- checkProperties is run (see code below marked with STEP 2).
- the report template is examined, an engine object is created.
- checkProperties with an engine parameter is run (see code below marked with STEP 3).
- the report is executed, the report servlet sends back the binary data to the report viewer running in the client's HTML page.
- Since:
- 6.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReportServletJSP()
Initialize a ReportServletJSP object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doWriteHtmlPage(java.util.Properties props, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
This method sets up a properties object for you and calls _jspService(req, res) which is the HTML page you have written translated into java code.void
init(javax.servlet.ServletConfig config)
Initialize the servlet and logs the initialization.void
jspDestroy()
Method will be called when the JSP container attempts to destroy the JSP servlet.void
jspInit()
Method will be called when the JSP container initialize the JSP servlet.-
Methods inherited from class com.inet.report.servlets.ReportPluginServlet
afterPropertiesStoredHook, destroy, doExecRequest, getPathSpec, service
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
-
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
Initialize the servlet and logs the initialization.- Specified by:
init
in interfacecom.inet.http.PluginServlet
- Specified by:
init
in interfacejavax.servlet.Servlet
- Overrides:
init
in classcom.inet.report.servlets.ReportPluginServlet
- Parameters:
config
- servlet configuration information- Throws:
javax.servlet.ServletException
- if an exception occurs that interrupts the servlet's normal operation- Since:
- 6.0
-
jspInit
public void jspInit()
Method will be called when the JSP container initialize the JSP servlet.
If you override this method, make sure to call `this.init(getServletConfig()'.- Specified by:
jspInit
in interfacejavax.servlet.jsp.JspPage
- Since:
- 6.0
-
jspDestroy
public void jspDestroy()
Method will be called when the JSP container attempts to destroy the JSP servlet.
If you override this method, make sure to call `super.jspDestroy()'.- Specified by:
jspDestroy
in interfacejavax.servlet.jsp.JspPage
- Since:
- 6.0
-
doWriteHtmlPage
public void doWriteHtmlPage(java.util.Properties props, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.io.IOException, javax.servlet.ServletException
This method sets up a properties object for you and calls _jspService(req, res) which is the HTML page you have written translated into java code. For example you might have given the following HTML code:
Note that within your JSP all checkProperties callbacks are available. For example:<HTML> <HEAD><TITLE>My Report Viewer</TITLE></HEAD> <BODY bgcolor="C6C6C6"> <applet code="com.inet.viewer.ViewerApplet" codebase=<%=props.getProperty("http_server_port") + "/client" %> id=ReportViewer width=100% height=100%> <param name=ReportName value=<%=props.getProperty("report") %> > <param name=HasGroupTree value=false> <param name=HasExportButton value=true> <param name=HasRefreshButton value=true> <param name=HasPrintButton value=true> <param name=HasLoggingEnabled value=true> <param name=HasTextSearchControls value=true> <param name=Archive value=<%=props.getProperty("http_server_port") + "/core/ReportViewer.jar"%> > </applet> </BODY> </HTML>
public void checkProperties (Engine engine, Properties prop, Object serviceRequest) { // examine parameter fields Fields df = engine.getFields(); for(int i=0; i<df.getPromptVarFieldsCount(); i++) { PromptField f = (PromptField)df.getPromptVarField(i); System.out.println("PromptField# " + i + " : " +f.getName() + " " + f.getPromptValue()); } // examine formula fields for(int i=0; i<df.getFormulaFieldsCount(); i++) { FormulaField f = (FormulaField) df.getFormulaField(i); System.out.println("FormulaField# " + i + " : " +f.getName() + " " + f.getFormula()); } }
- Overrides:
doWriteHtmlPage
in classcom.inet.report.servlets.ReportPluginServlet
- Parameters:
props
- Report properties to use when creating the HTML pagereq
- HttpServletRequest to use for the call to _jspServiceres
- HttpServletResponse to use for the call to _jspService- Throws:
java.io.IOException
- if an exception occurs that interrupts the servlet's normal operationjavax.servlet.ServletException
- if there is a problem callingHttpJspPage._jspService(HttpServletRequest, HttpServletResponse)
- Since:
- 6.0
- See Also:
HttpJspPage._jspService(HttpServletRequest, HttpServletResponse)
-
-