Bug 46727

Summary: DefaultServlet - serving multiple encodings
Product: Tomcat 8 Reporter: Fred Toth <ftoth>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement CC: ftoth, murugan.black
Priority: P2    
Version: 8.0.x-trunk   
Target Milestone: ----   
Hardware: All   
OS: All   
Attachments: Minor refactor of DefaultServlet
DefaultServlet refactor - patch

Description Fred Toth 2009-02-17 15:01:26 UTC
Created attachment 23272 [details]
Minor refactor of DefaultServlet

Hi,

It had to happen sooner or later. In one of my tomcat applications I now have to serve multiple collections of static content which may have various encodings. We depend heavily on DefaultServlet, but in its current state it is not possible to control encoding on a resource-by-resource basis. One can set the "fileEncoding" parameter, but this controls all static resources.

The structure of the current code makes this impossible to solve by extending the class, since fileEncoding is a global instance variable.

The attached refactoring mitigates this primarily by changing the method signature of serveResource() to contain an encoding argument. The extending class may override this method on every call if necessary.
Comment 1 Mark Thomas 2009-02-17 15:10:14 UTC
Patches should be in diff -u format
Comment 2 Fred Toth 2009-02-17 15:30:12 UTC
Created attachment 23273 [details]
DefaultServlet refactor - patch

Hi,

Resubmit as a patch.

Thanks,

Fred
Comment 3 Mark Thomas 2013-09-18 13:22:49 UTC
Sorry it has been rather a long time getting back to this.

A variation of this patch has been applied to 8.0.x and will be included in 8.0.0-RC3 onwards.

Since this patch changes the default servlet signature and it is likely that folks have extended the default servlet, I don't think it would be a good idea to back-port this to earlier versions of Tomcat.