inject javascript on head ? possible?

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

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:
http://vaadin.com/forum/-/message_boards/view_message/96981

extend servlet ?
my web.xml is like this ?
I will add MyApplicationServlet as new servlet ?
or I will do this?
from:
Vaadin Application Servlet
com.vaadin.terminal.gwt.server.ApplicationServlet
to:
Vaadin Application Servlet
com.myapp.MyApplicationServlet

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 http://java.sun.com/portlet_2_0 /WEB-INF/tld/liferay-portlet.tld
<context-param>
	<description>Vaadin production mode</description>
	<param-name>productionMode</param-name>
	<param-value>false</param-value>
</context-param>

<servlet>
	<servlet-name>Vaadin Application Servlet</servlet-name>
	<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
	<!-- replace standard applicationServlet with the ICEpush one -->
	<!--<servlet-class>org.vaadin.artur.icepush.ICEPushServlet</servlet-class>-->
	<init-param>
		<description>Vaadin application class to start</description>
		<param-name>application</param-name>
		<param-value>myapp.vaadin.MyVaadinApp</param-value>
	</init-param>

	<init-param>
		<param-name>widgetset</param-name>
		<param-value>myapp.gwt.MyAppWidgetSet</param-value>
	</init-param>

<load-on-startup>1</load-on-startup>
</servlet>
Vaadin Application Servlet /*

Hi! You probably figured this out already, but yes, you should change the
com.vaadin.terminal.gwt.server.ApplicationServlet
to point into your servlet class (in this case
com.myapp.MyApplicationServlet
) 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.