ericr29
asked on
java.lang.NullPointerException - Cannot Understand Why.
The code below compiles but I keep getting a "java.lang.NullPointerExce ption" error on line 72 at runtime.
Can someone tell me why? This code calls a .jcx (control) file to query a database and return a RowSet.
Can someone tell me why? This code calls a .jcx (control) file to query a database and return a RowSet.
package Main.pdfGen;
import Main.cntrls.*;
import com.bea.wlw.netui.pageflow.Forward;
import com.bea.wlw.netui.pageflow.PageFlowController;
import java.io.*;
//iText imports
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import javax.sql.RowSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import javax.naming.NamingException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @jpf:controller
* @jpf:view-properties view-properties::
* <!-- This data is auto-generated. Hand-editing this section is not recommended. -->
* <view-properties>
* <pageflow-object id="pageflow:/Main/pdfGen/PdfGenController.jpf"/>
* <pageflow-object id="action:begin.do">
* <property value="80" name="x"/>
* <property value="100" name="y"/>
* </pageflow-object>
* </view-properties>
* ::
*/
public class PdfGenController extends PageFlowController
{
public search searchCNTRL;
public RowSet pdfRowSet;
/**
* This method represents the point of entry into the pageflow
* @jpf:action
*/
protected Forward begin()throws IOException,SQLException,NamingException
{
HttpServletResponse res;
HttpServletRequest req;
ServletOutputStream out;
res = this.getResponse();
req = this.getRequest();
res.setContentType("text/HTML");
out = res.getOutputStream();
String report = req.getParameter("report");
String dir = req.getParameter("dir");
String field = req.getParameter("field");
String value = req.getParameter("value");
String cnt = req.getParameter("cnt");
/*out.print("<html><head></head><body>");
out.print("Report: " + report + "<br/>");
out.print("Dir: " + dir + "<br/>");
out.print("Field: " + field + "<br/>");
out.print("Value: " + value + "<br/>");
out.print("Cnt: " + cnt + "<br/>");
out.print("<html><head></head><body>");*/
if(report.equalsIgnoreCase("report_1")){
// Get DB rows
pdfRowSet = searchCNTRL.getReportRows(value,"lower(column)","ORDER BY column ASC",0,Integer.parseInt(cnt));
}
out.flush();
out.close();
return null;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So the code above would be changed to look like this:
public class PdfGenController extends PageFlowController
{
public search searchCNTRL;
searchCNTRL = new search();
public RowSet pdfRowSet;
...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
searchCNTRL = new search();
..before you use any methods of searchCNTRL. Hope this works.