2

Below is snippet from a JSP file. Earlier I had used scriptlet (<%=request.getContextPath()%>) to populate the context path as shown in [A]. All 3 javascript files were being imported.

[A] 
<script language="JavaScript1.2" type="text/javascript" src="<%=request.getContextPath()%>/js/a.js"></script> 
<script language="JavaScript1.2" type="text/javascript" src="<%=request.getContextPath()%>/js/b.js"></script> 
<script language="JavaScript1.2" type="text/javascript" src="<%=request.getContextPath()%>/js/c.js"></script> 

I replaced the contextpath population using EL(Expression Language) as shown in [B]. I also modified javascript files a.js and c.js and added some functions. I redeployed my application ear. I see that the new file a.js is reloaded in the browser (IE) cache, but c.js remains unchanged.

[B]

<script language="JavaScript1.2" type="text/javascript" src="${pageContext.request.contextPath}/js/a.js"></script> 
<script language="JavaScript1.2" type="text/javascript" src="${pageContext.request.contextPath}/js/b.js"></script> 
<script language="JavaScript1.2" type="text/javascript" src="${pageContext.request.contextPath}/js/c.js"></script> 

Why does this happen? I suspect that javascript errors in one of these external files (probably b.js) is preventing c.js from loading. Has anyone come across such a scenario. Please reply . Thanks.

Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160
Mandar Lad
  • 21
  • 4
  • If you navigate to the JS file manually (in your browser) do you see the old or new version of c.js? – nickdos Sep 06 '12 at 06:06
  • This might be useful http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files – nickdos Sep 06 '12 at 06:41
  • Hi Friends, I have found the problem. JavaScript file c.js had some compilation problems like missing semi colon etc. After removing those issues, file c.js also gets reloaded in browser. So I would conclude that when EL is used to import javascript files in JSP, compilation checks are performed on each file. This is not true when scriptlets are used. – Mandar Lad Sep 06 '12 at 09:54
  • I doubt that very much - probably case of caching and then cached flushed after the change to EL. So coincidence. – nickdos Sep 07 '12 at 01:29

0 Answers0