struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Belfer-Shevett <>
Subject Bizarre sporadic problem with streaming a stylesheet.
Date Tue, 21 Sep 2010 04:36:59 GMT
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; charset=UTF-8">
	<LINK REL="StyleSheet" href="getConfiguredStylesheet.action" 

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 = sc.getResourceAsStream("/public/web-emphasis.css");
		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 response...");
	} 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 stylesheet...
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:

View raw message