This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts Loop breaks at specific number of characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Loop breaks at specific number of characters" Watch "Struts Loop breaks at specific number of characters" New topic

Struts Loop breaks at specific number of characters

David D Myers

Joined: Dec 14, 2011
Posts: 3
I have a jsp which has a struts loop "logic:iterate" which displays all of the delivery basis entries in the database. However, once the loop has output a specific number of characters to the screen, it stops all output and the entire page breaks immediately.

The specific number of characters is evidenced by the fact that removing one character from what the loop outputs each iteration results in the loop outputting what appears as more of the page. For example the current loop looks like this:

There are currently 18 rows in the delivery basis table, but the break is happening before the loop can finish. As a result this loop outputs 12 tr's but on the last iteration it only gets as far as the "<a" for the removal link. Let's say you remove 1 character from the code, for example deleting 1 character from the href value. By doing this the number of characters output each iteration will decrease by 1. This will make the loop appear as if it outputs more of the code, when in reality it is outputting the exact same amount of characters.

In our example instead of stopping at "<a" the loop will stop at '<a style="text'. At first glance it would appear as if more characters had been output, but if you remember that we decreased the number of characters output during each iteration by 1, and the fact the there are currently 12 iterations, you realize that the same overall amount of characters has been output. If you notice, ' style="text' is exactly 12 characters.

My question is what could be causing this to happen? Is there a setting or configuration in the code that needs to be set properly?
Joe Ess

Joined: Oct 29, 2001
Posts: 9191

David D Myers wrote:
My question is what could be causing this to happen?

My wild guess is that your server is buffering output, so your browser is receiving data in chunks and you are getting the latest chunk that has been completed before the error occurs in your processing. By tweaking the JSP, you can change what gets written to the browser before output terminates. While this is interesting behavior, it is not really relevant to the actual problem.
What causes the page to stop processing? Do you get an exception in the logs or console?

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Struts Loop breaks at specific number of characters
jQuery in Action, 3rd edition