File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null Arguement Question

 
Bernard Bobinski
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a report called the Daily Bulletin I have a notification section. One of the fields is entitled NARRATIVE. If the rpdnotification table is empty, can I set the value of NARRITIVE to "None at this time" and have is display the same? I have tried several times but get no results. My code for that section is as follows.

TABLE rpdnotifiation
FIELDS are subject, authority, narrative, startdate, rundays, and rundays

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can I set the value of NARRITIVE to "None at this time" and have is display the same?


I have no idea what you are asking as NARRITIVE [sic] (or even NARRATIVE) does not appear anywhere in your code. Java is case sensitive, as you know. Are you talking about the db column? the scripting variable?

What are you trying to set?
[ September 08, 2004: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note: when the table is empty, you get no results and your loop will never execute.

Btw, did I mention that doing SQL and dealing with result sets in a JSP page is evil? Best practice is to deal with this sort of stuff in a servlet and forward to a JSP page with a plain old collection containing your data for view.
 
Bernard Bobinski
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry - NARRATIVE refers to narrative. There is a lot more to this page than what is displayed. The actual page is over 600 lines long. I only posted the section I was having trouble with.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about changing:

Jules
 
Bernard Bobinski
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried your code - the results are still negative. Question - Does it have something to do with the WHILE LOOP. Does the LOOP have to be broken to show desired results?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see anything wrong with your JSP code, however your HTML sucks. You've got <tr> inside <td> without an enclosing <table> (I'm not talking about outside the while loop, I mean inside it)[Edit: actually that's not true; I just didn't spot it as it wasn't indented - apologies]. You've also got extra closing tags, e.g. </strong>. It's possible that the malformed HTML is not helping the situation. Perhaps it's worth checking that out. Meanwhile I'm just going to knock up a quick example.

Jules
[ September 09, 2004: Message edited by: Julian Kennedy ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused about what has you confused. You have stated that the table is empty, and yet you seem to be surprised that that results in no data being displayed.

As I stated before, with an empty table you get a zero-length results set; therefore rs.next() returns false, therefore the body of your while loop never gets executed, therefore no output.

What am I not getting?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, this self-contained page, which basically incorporates your code, works perfectly for me (looks bloody awful, but works perfectly!):

The top part mimics a SQL ResultSet.

Now, after all that I think I may have completely missed the point which is, as Bear has said, that if you're not getting any results back then your loop will never be executed, your rows will never be created and you won't get any output beyond the static stuff. If you want to display "none at this time" when there are no results you'll need to check that after you've executed your query and display your message instead of doing the while loop.

Hope this helps.

Jules
 
Bernard Bobinski
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Took your adive and solved the Null Argument Problem. I attacked the problem form a new angle and ended up successful. I used the following code.

bullNotificationTrue.jsp - Displays Query Results
bullNotificationFalse.jsp - Displays "None at this time"




Thanks again for the help
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic