• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Javascript import fails when using EL

 
Greenhorn
Posts: 3
  • 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
 
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Bartender
Posts: 1845
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: 3
  • 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
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic