• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript import fails when using EL

 
Mandar Lad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

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 which is preventing c.js from loading.)
Has anyone come across such a scenario. Please reply asap. Thanks.

Regards,
Mandar
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the HTML delivered to the browser is the same, there should be no differences in behavior -- at least not caused by the JSP.
 
Stefan Evans
Bartender
Pie
Posts: 1669
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that would imply you view source on the generated page, make sure that the ${el expressions} are being evaluated and if not, then check out the FAQ for EL not working as expected
 
Mandar Lad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,
Mandar
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mandar Lad wrote:
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.

Your conclusion is not correct. JavaScript files are not checked by the JSP container at all regardless of whether you use the EL or obsolete scriptlets.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic