Reputation: 45
how can I do this? I read about compression, but not find anything about doing in embedded tomcat server. I read about Connecter class set the compression on in this website
http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/
but not in server. I have main method which starts tomcat server.
Upvotes: 2
Views: 597
Reputation: 720
Anything you can do via XML can (most likely) be done with API calls through Java as well. In this case, if you can get a handle to the Connector object, you could probably set whatever values etc and enable compression.
Have you tried that? It would be something to the effect of
Tomcat server = new Tomcat()
Connector connector = server.getConnector()
Now set whatever values you want in your compression and after you are done, make sure to set the connector object back into the server
server.setConnector(connector)
I think that should be equivalent to the declarative way that's listed in the link you posted.
Upvotes: 2