Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • 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

separating out the js from jsp

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My javascript knowledge is not very sound. I have the following javascript in the jsp page and I don't want it to be in jasp, rather I have tried to move the js related code to .js file and tried to include it in the jsp.
But it's not working. any suggestion on how to do this?
And also what is the best practice to follow to avoid the javascript compatability problem with browsers?

 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving the script (learn to indent!) to an external file should not be an issue. Chances are you are not addressing the file properly and so it's not actually getting loaded.

Gander at the JSP FAQ for info on successfully using server-relative URLs to address resources such as JS files.

Your best bet for avoiding those rage-inducing browser differences is to employ a JavaScript library that has already done all the hard work for you. I personally am a big fan of jQuery (to the extent that I ended up writing a book about it).
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic