BersaKAIN BersaKAIN - 9 months ago 65
Javascript Question

How to include a javascript in a jsp page

I am new to J2EE and Web development. Here is my issue:
I want to include angular.js in the webpage.

Here is the version that works:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src=""></script>
<title>Lets Meet Up!</title>

But I also want to have some local javascript files, and hopefully, I want to import the angularjs in the local directory

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="WEB-INF/lib/angular/angular.js"></script>
<title>Lets Meet Up!</title>

The the page is unable to run the javascript.

My stack is Tomcat, Spring MVC, Spring, J2EE
I put the angularjs source in

Anyone can help? THanks!!

Answer Source

Files in WEB-INF are inaccessible.

Put angular.min.js and all other static assets at the top level of your war file. Or better yet in some nice folder like js/angular/angular.min.js at the top level.

Then do this

<script src="js/angular/angular.min.js"></script>

Depending on your needs you might want to consider serving your assets from a CDN, but that's another story altogether.