Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Configuring Jetty to modify the <head> element

That can be very tricky.

First, there's no built-in function to do that.
So you'll have to write the html parsing & modification routines yourself.

This could be done via a Servlet Filter or a Jetty HandlerWrapper, in either approach you'll want to wrap the HttpServletResponse to capture & modify the response, and pass that wrapper down into the filter chain (or handler wrapper chain).

Tip: response isCommitted can be a point of no return (esp for response Content-Length), so keep that mind.

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Thu, Dec 11, 2014 at 7:45 AM, Michael Monaghan <mickmon@xxxxxxxxx> wrote:
For testing purposes, I need to modify the <head> element of all the text/html content generated by a large complicated app.

I need to add a _javascript_ include to the <head> element.

The work required to do this in the app itself is likely not trivial. I don't own the app, and don't fully understand the architecture etc. There's little or no static HTML here.

Is it possible to have Jetty modify the <head> element of the content that it serves?

Thanks for your time.

jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top