Subscribe to
Posts [Atom]


getting the application context in javascript

Monday, October 09, 2006

first you create a jsp page with the following content:
<%@page contentType="text/javascript"%>
var context ='"\'<%= request.getContextPath() %>\'"';

note: the context will have a string with the quotes still around it so these will need to be trimmed

then in the page or place javascript is included in your program include this file, for example:

script type="text/javascript" src="ContextPath.jsp" (surrounded by script tag)

the above context varialbe is now a global javascript variable

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home