Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Big String getting garabled in display  RSS feed

 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm displaying a large string in a JSP with the following code:
<%= simulation.getIntroduction() %>

(BTW, this is inside of a table. And the string is originally pulled out of a MySQL database using hibernate.)

For really long pieces of text - I experiment with this using 'The Cask of Amontillado' - the display gets garbled. Its like the first half of the string arrives, and then the second half arrives. BUT, when I look at the html source, it all seems well formed.

Any ideas on how to work around this issue? It seems like more of a browser issue than anything else. The string is arriving. Do I need to make the JSP wait until everything has arrived before it starts rendering? If so, how do I do that?

Thanks in advance,
Skip
 
Sunil Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This happens when the string contains something that interferes with the intended html codes. Like having <something>, & (ampersand) etc
Please check if your string does have those.
For this you will need to replace by html equivalent


In your case it appears to be the single quote
[ December 28, 2008: Message edited by: Sunil Kumar ]
 
Sunil Kumar
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick link for such equivalents http://htmlguide.drgrog.com/alpha/isocodes.html
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sunil, I have no idea what HTML-encoding has to do with this issue. The sample string the OP posted has no characters that require encoding, and even if so, would not result in the described behavior.

If the HTML is well-formed, there is little you can do to alter the behavior of the browser. Have you tried it on other browsers to see if the behavior is browser-specific or not?

P.S. 'The Cask of Amontillado' is hardly a "big" string.
[ December 28, 2008: Message edited by: Bear Bibeault ]
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sunil,

Thanks for your posting. Unfortunately it is not a special character issue.

I created 768 lines of the string:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

and reproduced the exact same issue.

But thanks for the links and the notes on special characters. I will probably have to deal with those at some point as well.

Best,
Skip
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bear,

Good point on trying it in different browsers. I forgot to mention that I had tried it in Google chrome and got the same result. (I normally work in Firefox.)

I have now tried it in Explorer and get the same display problem.

But, and this is interesting, when I look at the source in explorer, I see this in the middle of the big string:
aaaaaaaaaaaaaaaaa</TR>
aaaaaaaaaaaaaaaaaaaaaaaaaa<br>aaaaaaa...

So IE appears to show the source more true to what is being rendered, that is to say, all messed up.


Thanks,
Skip
[ December 28, 2008: Message edited by: Skip Cole ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the <br> is not appearing in the source of the other browsers?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[edit] nevermind.
[ December 28, 2008: Message edited by: Bauke Scholtz ]
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bear,

The <BR>s show up in the source as seen on all browsers.

But the </TR> is only showing up in the source as seen on IE 7.

Best,
Skip
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bauke,

Actually, what I'd like to do is add a <div> show/hide control to allow the viewer to see or not see the large block of text.

I figure there are plenty of work-arounds for this issue. I can check the size, put it in an iframe, etc.

But it just seems maddening that plain text aimed for display in a JSP doesn't show up right simply because there is too much of it. Its just Not supposed to be this way :-)

Best,
Skip
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Skip Cole:
But the </TR> is only showing up in the source as seen on IE 7.
Different sources depending upon browser is plain weird. At this point you're going to have to show us what you're doing on the server in your JSP.

Clearly there's something more going on than "just too much text".
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm...

I'll try to figure out a way to concisely post the pertinent code.

I am pulling the object out of the database using Hibernate. That may be part of the issue.

When I find a way to concisely post the problem, or when I have more clues, I will post here to this thread again.

Thanks!
Skip
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Skip Cole:
That may be part of the issue.
I'm not sure how. Inspect the data when it gets to the UI layer, and inspect the code used to format it for view.

Be sure to use UBB code tags when posting code.
 
Skip Cole
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found it!

The page we are displaying is long and complicated. It describes all of the settings for a simulation. Later on in the page it shows information on the various phases of the simulation. We wanted these in columns of three so I was modifying the display depending on how many were present.

To cut to the chase, I replaced:


With:



And the string interruption problem went away.

The problem now is that I can't see my page in Dreamweaver the way it should look. The extra throws the WYSIWYG display off.

I guess what was happening is that the page is displaying in the browser when that PrintWriter (operating on a separate thread?) gets called and inserts the html code for row termination.

I think the question has now become:
How do I have my JSP print out a in the right place, but not have it mess up my display in the WYSIWYG editor?

Thanks!
Skip
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer would be not to have a long and complicated JSP page with Java scriptlets in the first place. Factor the processing out into the page controller and use scriptless JSP pages with the JSTL and EL.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!