I am using Struts 1.1, Tomcat 4.1.12 on Windows XP
I am trying to add some JavaScript to a JSP page To do this I am including one or many JavaScript source files using the following style;
<script language="JavaScript" src="/pages/templates/code.js"></script>
<script type="text/JavaScript" src="/pages/templates/data.js"></script>
Directory structure Webapps/App/WEB-INF/pages etc
When I try to call a function in these sources, the function fails with the error message that the function is undefined.
If I take the source out of these files and put it in the JSP pages within a single
<script language="JavaScript" > ... all the code form code.js and data.js ...</script>
tags the issue is resolved, although this is to messy for my liking.
I have been checking the forums but this seems not to make sense as the former is supposed to work.
Have you experienced anything like this? or can you think of some reason that the system behaves like this?
I have tried to put these between the <Head> tags and elsewhere with the same result.
I have also tried this from HTML pages and they are served properly with the code executing on the browser.
An entry for js files is present in my web.xml file.
- <mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>
I am trying to add some JavaScript to a JSP page To do this I am including one or many JavaScript source files using the following style;
<script language="JavaScript" src="/pages/templates/code.js"></script>
<script type="text/JavaScript" src="/pages/templates/data.js"></script>
Directory structure Webapps/App/WEB-INF/pages etc
When I try to call a function in these sources, the function fails with the error message that the function is undefined.
If I take the source out of these files and put it in the JSP pages within a single
<script language="JavaScript" > ... all the code form code.js and data.js ...</script>
tags the issue is resolved, although this is to messy for my liking.
I have been checking the forums but this seems not to make sense as the former is supposed to work.
Have you experienced anything like this? or can you think of some reason that the system behaves like this?
I have tried to put these between the <Head> tags and elsewhere with the same result.
I have also tried this from HTML pages and they are served properly with the code executing on the browser.
An entry for js files is present in my web.xml file.
- <mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>