Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataInputStream, Mystery null

Status
Not open for further replies.

cpope

Programmer
Jul 7, 2000
58
US
Currently I am running a servlet that reads data from a URL generated by another servlet on another machine. The problem I am experiencing is missing data being replaced by a null. When I cut and paste the URL, the data appears to be fine. I use the same class to read from the URL for other purposes without any problems (different data based on call, same URL).

Here is the code that reads the URL (the URL is well formed, if cut and pasted into the address location of the browser with the variables, the data appears fine):
/***********************************************************
Check URL input
***********************************************************/
fName = " + strBillAcct + "&CALLTYPE=" + strCallType + "&BILLDATE=" + strBillDate + "&BILLSEQ=" + strBillSeq;

try
{
URL inBill = new URL(fName);

DataInputStream server = new DataInputStream (inBill.openStream());
while((s = server.readLine()) != null)
{
lnCnt += 1;
strData += s;
}
server.close();
strCallError = "Sucessfull Call - " + lnCnt + " lines read!";

}

catch(FileNotFoundException e)
{
strCallError = "File not found " + fName;
}
catch(IOException e)
{
strCallError = "IO Exception for " + fName;
}

When the URL is Cut and Pasted the data returned is:

OK RLKTDAT U REGR1000000900 crider1 crider crider crider@email.com 2j7jHMzSWAbg104162170 N

The servlet reading the URL is returning:
OK RLKTDAT U REGR1000000900 null N

What I need to know is why null is getting returned in the place of data, when the data is there when you cut and paste the url into your browser??

Any suggestions would be appreciated!
 
I found the problem, it was that there was spaces in the URL. When cut and pasted, IE automatically replaced spaces with %20, When I changed the code to do the same thing, the problem was solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top