Can somone tell me why I can't load few *.js scripts from JSP file <head> section?
I've tried but server loads just first file, rest it's skipped.
It's becouse of performance issue?
How I suppose to include few js file without combining them into one file? (one js works fine), is there any method to join them?
Walter Krawiec wrote:I've tried but server loads just first file, rest it's skipped.
The server has nothing whatsoever to do with it. There is no reason on earth that you cannot include multiple script files. I do it all the time.
And it certainly has nothing to do with JSP, since only an HTML file is sent to the browser.
It's most likely that your script file URLs are invalid.
Max Rahder wrote:
Walter Krawiec wrote:Can somone tell me why I can't load few *.js scripts from JSP file <head> section?
You can use <jsp:include page="" /> to include as many files as you'd like. If you want to include 5 .js files, then use 5 includes.
Not a good idea. In fact, it's a pretty bad one. That will cause the JS to be included in-line and prevent any caching by the browser.
Once again, there is nothing short of a code error that can cause this to happen. Fix the code rather than looking for weird work-arounds.
Bear Bibeault wrote:I think you misunderstood him.
I think that the only JSP-ness to this issue is that the URL's to the JS scripts are likely invalid, probably due to not using the context path properly, as is usual in these cases.
But until the OP posts his code, we can't know.
normally I'm adding few files inside <head> section:
it's working for first file in queue, i've tried to swap between these file and each file was loaded properly but still just first one..
1. I squeezed all scripts into one js file, after loading page file is loaded but in firebug there is an error: "" is undefined".
2. Second option is to load js files by using this option works for one js file. if you try to load next one it will be skipped.
I do not understand where is the issue, normally Glassfish loads few files automatically for particular components like: dropdown menu, accordion etc...,
Can somone enlight me?
so better if you check your first js file OR you can do 1 more thing change the order of file which you are using i mean put first js in last.
It is also a good practice to put all .js files in last of the jsp page if you are using many js files because when your page will be loaded on web browser first it will load all .js files after that your view will be displayed. In this case user have to wait a little long.so better provide view & then js should be loaded. This should be used if your page is not using js files initially OR if this approach not affecting your business logic.
of course modify it to suite your needs.
the -part tells the browser where the files are relative to where they are deployed. If you don't do this and the application is moved from one location to another the paths wont be correct and the browser won't find the files.