Web tier: servlets, JSP, Web frameworks: Where to put: Common Javascript functions

  1. Where to put: Common Javascript functions (1 messages)

    Hello everybody,

    I have some common javascript functions which will be used most of the JSPs. I want to create as a library file and put it in one place and include this common file into all JSPs(if required).

    question is what type of common file should be created ? is this another .jsp or .txt (which contains all javascript functions.

    and how to include it in JSPs?

  2. Hi ,

    All Functions should be written in a common file named as <file Name>.js . This extension can be anything.

    This file can be included in respective jsps using following tag ,

    <SCRIPT language="javascript" src="library.js"></SCRIPT>
    This tag will add all library function to that jsp.

    Now you can call methods written in library.js file.

    ~ @bhijit