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

Sudden slowdown in jsp rendering  RSS feed

 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks, I've started to experience a weird lag in the generation of my jsp pages. The pages basically generate a header then loop through a series of rows representing the data I'm displaying, it's a typical "data-centric" page, no fancy javascript. The header is displayed instantly, then right before generating the rows it stalls anywhere from 2 up to 4 or 5 seconds, depending on how much data is to be returned. Then after stalling the rows are displayed very quickly. I can't think of anything I'd done to cause this change. There hasn't been a change in the amount of data being displayed. I see this happen with both tomcat 5 and jrun 4. I'm using an explorer 6 browser. No database connection either. I placed some simple print statements where I execute the retrieval of the data in the "business logic" section, that part is very fast, I narrowed it down to the actual jsp rendering. I played with the buffer attribute in the page declaration, nothing changed. Any ideas? It's kind of a weird problem.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the appserver running low on memory (and thus being forced to gc with each hit)?
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tailed the free memory before page generation: 21,499,064 and after page generation: 21,500,720 , I actually gained a little, but not enough to have it look like gc was executed. There is definitely a correlation between the length of stalling and how many rows of data I have to display. I'm setting the data at request scope, the session tracking for the jsp page is turned off. I also timed the request dispatcher as well, that was real fast. It's just weird, it used to never stall, the page would render itself in one shot.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I assume you've ruled out a slow network connection?
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah no network issues. It just seems to want to pause before looping through the data. I couldn't get much from ramping up the buffer size as well. The data being returned, even at it's largest, isn't *that* big only 220 kb. At least I don't think that's big.
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just did another interesting test, I placed a print statement in the jsp file after the closing bracket of the loop tag. The print statement executed well before the data actually was displayed. It seems like the jsp engine needs to pause to build the html, when it used to never have to. Could there be some strange setting some place I had inadvertantly changed?
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so it's getting generated but your browser doesn't display it.

Did you change the layout of your page? If you use complex html tables where previously you did not that may slow down rendering by the browser quite seriously.
In such cases adding size (width and height) attributes to html elements can help a lot.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have access to a packet sniffer you could watch the traffic being sent down the wire. Then you'd know if the pause is on the client or server machine.

Also, do you have any antivirus software on the client machine trying to read everything before displaying it?

Did you try with Firefox/Mozilla?

Just for kicks, you might want to try increasing the memory to Tomcat(although your previous statements make me doubt that that's it). The default is 64m.
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't changed the html, but I did change my css file some. I consolidated some styles, removed unused ones, and improved the sheet so that nested elements would get the correct styling. I had thought that might be the cuplrit and so removed the reference to the css file altogether, but it made no difference. I've also used a couple other developer's computers and pulled up the site, it does the same for them, so it's not some browser cache setting on my side. I do have virus software, but it hasn't changed in a while, and I don't see this behavior with other sites I download.
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it was an html issue. I saved off the 'view source' of my generated jsp page and then opened it up in a browser completely outside the server. And the rendering was just as slow, even after hitting refresh. So the thing is, my html generated by jsp is fraught with whitespaces. So I cleaned up a couple of rows of data and removed all the unnecessary spacing, then copied that row about 300 times into the page, and the page rendered itself in a flash. So, the question I have now is removing whitespace. I've heard tomcat has a property that could be set to remove them, does Jrun 4 have such a property? I think this is also done automatically when using a jsp:getProperty tag. Problem is I'm printing my values out using <%= %> commands. Is it true there's no way to use a getProperty tag with a variable declared from a scriptlet? The variable has to be introduced to the page via some sort of useBean? Does anybody have ideas on removing whitespaces.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The property you're thinking of in Tomcat isn't going to remove whitespace introduced by you. It just keeps the <jsp:... tags from creating their own white space.

I'd say to enable gzip compression but the problem doesn't seem to be network related, it's the actual rendering time in the browser.

This would be a good job for a filter. Intercept the response and rewrite the printWriter stream..

I bet someone's already written one.
[ January 19, 2005: Message edited by: Ben Souther ]
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben, thanks for the help with this. All the extra spacing came from some if clauses I had in my jsp file. I basically removed all scriplet code and made it so the bean's getter methods sent the values just they'd be needed to the jsp pages, probably a better way of doing things from a mvc standpoint anyways. This resulted in much cleaner looking html when it was all rendered. It sped it up a bit, so this did help. I thought of the filter idea, but the effort wasn't worth the result. Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!