including javascript file in a jsp file

“how to include a javascript file (external .js file) into the jsp files?”. it is all about. It can be achieved by using “<script>” tag as follows

<script language="text/javascript" src="../path/to/your/javascript-file.js"/>

This link helps you for the same -> http://www.w3schools.com/js/js_whereto.asp

It all started off with the inclusion of a javascript calendar in a Web application what i am developing! At first i had searched for some cool javascript calendar stuff in google.  Though got a couple of links, got impressed very much this DHTMLGoodies stuff. The reason being it satisfies my exact requirement as it does NOT not only capture the date but also the time which is what i needed. Look at the section “A date picker for form” which is in the middle of the page.

But the issue always start with customization :). As the demo page was having some other types of calendars, i had to omit those. But my gimmics on the mimic was not working as i kept getting an ‘Object expected‘ error in the IE browser! Felt very bad and tried some work arounds, finally somehow managed to get this thing done! The real action i was doing was keeping the html page outside the folder which was actually inside a folder named ‘demos’ in the downloaded DHTMLSuite package zip file. But it dint seem to be working and i was going crazy what might be causing so. Well, one of my colleagues also attempted to debug and finally we have decided that it should be under a folder and its name should also be ‘demo’. He even searched for the same in files in demo directory for being hardcoded! I was telling that it should never be the way.  i asked him to recheck by giving a different name and he gave the name as ‘xxx’. Crazy fellow :). It did work 🙂

Finally, the mistake was there in the naming convention of .js file. There was an error in the filename as the actual filename was having a mixed camelCase (fileName.js) but inside it was referred all in small case! 😦 yuck.. It is again a silly copy-paste error! 😦

This is how we tend to do the mistakes on the things which we know we are comfortable with. Aint I?

10 comments so far

  1. meenu on

    total tech post
    me and java jsp all are like pluto and earth !:D
    so sorry .. dint get much ..

  2. Vidya on

    Gosh Raghs, this is very technical for me ! 😦

  3. raghs on

    @Meenu,

    Yes, i agree.. 🙂 no issues..

  4. raghs on

    @ Vidya,

    Gosh? Me? :(.. haha. thanks anyways for dropping by.. you could have looked at other entries.. lol 😛

  5. Shreyas on

    Nice one.

    Your colleague surely knows the naming convention!

    Can you also tell me how to use some random css sheet with say, to my simple login page in netbeans.

  6. PSpot on

    Excuse Me..
    Your blog has been listed in பதிவுSpot
    And please tell me some more Taminglish Blogs to add this Taminglish aggregator. Thanks.

  7. raghs on

    @shreyas,

    Thank you and welcome here!

    random css sheet? I guess you have to have a small logic in your jsp wherein it has to embed the particular chosen css to be applicable!

  8. raghs on

    @Pspot,

    Thank you for having added my blog in PadhivuSpot. I would do my best! 🙂

  9. Sunil Kumar on

    Hi,the statement is wrong. It should be

  10. raghs on

    @Sunil,

    Welcome here. I guess you are yet to complete your say. Is there any other way we can do it? It would be glad if you can share the information.


Leave a reply to raghs Cancel reply