This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Fail to include js file in WEB-INF directory with angular ng-include

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I created a web project on tomcat apache 8

I am trying to include a jsp loacted in the WEB-INF directory.
I fail to include it with angular.

directory webapp contains : index2.jsp
directory webapp/WEB-INF contains : fragment1.html

index2.jsp code :

Why i fail to include fragment1.html with angularJS?

Itamar.
 
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resources placed under the WEB-INF folder cannot be accessed directly by the browser.
 
Itamar Levi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

"Resources placed under the WEB-INF folder cannot be accessed directly by the browser."
That is true. but I didn't access fragment1.html directly by the browser. i access it by including it in another jsp (index2.jsp)

And why does access the resource with <%@ include file="WEB-INF/view/fragment1.html" %> is working?

 
Marshal
Posts: 25965
70
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Itamar ab wrote:And why does access the resource with <%@ include file="WEB-INF/view/fragment1.html" %> is working?



That's because the <%@include %> operation is executed on the server as part of producing HTML from the JSP where that line is located. As already stated, the server can access things under the WEB-INF folder.

However the browser can't. And if I'm not mistaken, angular is a JavaScript library, and therefore it must be running in the browser. And therefore it can't access things under the WEB-INF folder.

 
Bear Bibeault
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Itamar ab wrote:
"Resources placed under the WEB-INF folder cannot be accessed directly by the browser."
That is true. but I didn't access fragment1.html directly by the browser


Yes, you did. That's what angular does. It's not at all like a JSP server-side include.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic