Bug 46727 - DefaultServlet - serving multiple encodings
Summary: DefaultServlet - serving multiple encodings
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-17 15:01 UTC by Fred Toth
Modified: 2013-09-18 13:22 UTC (History)
2 users (show)



Attachments
Minor refactor of DefaultServlet (72.86 KB, text/plain)
2009-02-17 15:01 UTC, Fred Toth
Details
DefaultServlet refactor - patch (5.61 KB, patch)
2009-02-17 15:30 UTC, Fred Toth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.