struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Mohan <>
Subject Re: Bizarre sporadic problem with streaming a stylesheet.
Date Tue, 21 Sep 2010 05:42:10 GMT

Did you take a look at this request through Firebug? It might show some 
useful info. Also, is the content type proper (text/css) in the request 
header? I can't see you setting it anywhere. 

- Rahul

Dave Belfer-Shevett <>
21-09-2010 10:07
Bizarre sporadic problem with streaming a stylesheet.

Help me obi-wan struts-geeks.  This one is puzzling me.

I need to 'stream' a stylesheet out to the browser.  Due to the app, 
that stylesheet is sort of generated on the fly from the database, so I 
can't just point the browser at a static file.

In the document, I have:
                 <meta http-equiv="Content-Type" content="text/html; 
                 <LINK REL="StyleSheet" 

Here's the method mapped to this (note this is at the moment reading 
from a file off the filesystem, not from the db - but even the comment 
in the StringBuffer doesn't show up)

public void getConfiguredStylesheet() throws IOException, Exception {
       "Fetching configured stylesheet...");
                 sessionData = ActionContext.getContext().getSession();
                 // Open up the .css file specified in the event
                 try {
                                 InputStream is = 
                                 logger.debug("inputstream for stylesheet 
should not be null.  It is: " 
+ is);
                                 BufferedReader br = new 
BufferedReader(new InputStreamReader(is));
                                 logger.debug("Setting up sb with basic 
stylesheet info...");
                                 StringBuffer sb = new StringBuffer("/* 
Read via CSSFetcher from 
web-emphasis.css */\n");
                                 String s ;
                                 int counter=0;
                                 while ((s = br.readLine()) != null)   {
                                                 sb.append(s + "\n");
                                 logger.debug("Stringbuffer counted " + 
counter + " lines, and is " + 
sb.length() + " bytes long.");
                                 logger.debug("Writing it to the 
                 } catch (Exception e) {
                                 throw e;

Here's the problem.

The stylesheet shows up in the browser - only about 4 times out of 5. 
Every 3rd, 4th, 5th, sometimes 6th webhit, there's no stylesheet.  The 
log, however, shows that the stylesheet went out - no matter whether 
it's available in the stylesheet viewer on the browser or not, the log 
always says:

2010-09-20 23:30:20,743  INFO [CSSFetcher] Fetching configured 
2010-09-20 23:30:20,743 DEBUG [CSSFetcher] inputstream for stylesheet 
should not be null.  It is:
2010-09-20 23:30:20,744 DEBUG [CSSFetcher] Setting up sb with basic 
stylesheet info...
2010-09-20 23:30:20,743  INFO [CSSFetcher] Fetching con-specific 
stylesheet information...
2010-09-20 23:30:20,744 DEBUG [CSSFetcher] Stringbuffer counted 259 
lines, and is 4889 bytes long.
2010-09-20 23:30:20,745 DEBUG [CSSFetcher] Writing it to the response...

My guess is there's some weird interraction with timing with how the 
stylesheet is being loaded and when the browser is expecting it to be 
completed.  I can't for the life of me figure out what it is.  The 
flush() and close() lines in the method were added to attempt to 'finish 
up' the connection, but they made no difference.



To unsubscribe, e-mail:
For additional commands, e-mail:

Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message