inject javascript on head ? possible?

Hi , i want to inject some global javascript on head and i will call them on

is it possible to inject js on head tag ?
if yes , how?

Hi! Yes, this is possible. You should extend the servlet and override the writeAjaxPageHtmlHeader method. Something like:

public class MyApplicationServlet extends ApplicationServlet {

    protected void writeAjaxPageHtmlHeader(final BufferedWriter page, String title, String themeUri) throws IOException {
        super.writeAjaxPageHtmlHeader(page, title, themeUri);        
        page.write("<script type=\"text/javascript\" src=\"your-javascript-file.js\"></script>");


Here is some more information also:

extend servlet ?
my web.xml is like this ?
I will add MyApplicationServlet as new servlet ?
or I will do this?
Vaadin Application Servlet
Vaadin Application Servlet

Here is my full web.xml as shown below:

<?xml version="1.0" encoding="UTF-8"?> ToCPanel-portlet index.html index.htm index.jsp default.html default.htm default.jsp /WEB-INF/tld/liferay-portlet.tld
	<description>Vaadin production mode</description>

	<servlet-name>Vaadin Application Servlet</servlet-name>
	<!-- replace standard applicationServlet with the ICEpush one -->
		<description>Vaadin application class to start</description>


Vaadin Application Servlet /*

Hi! You probably figured this out already, but yes, you should change the
to point into your servlet class (in this case
) instead. And your servlet class should then extend the ApplicationServlet and override the header writing method.

Or extend ICEPushServlet if using it - the Vaadin application itself is always served by a single servlet.