• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic