• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

separating out the js from jsp

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 67756
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
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 am mighty! And this is a mighty small ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic