Archive for the ‘css’ Category

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 ->

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?


referring the css files for webpages inside Netbeans IDE

If you are dealing with CSS (Cascading Style Sheet) files for the web pages inside Netbeans IDE, you need to know one thing.

It does not pick up the .css files as referred in the files which has the link to it. Generally, all other IDEs and Application Servers should work that way. But when i had been doing a J2EE based web application, i found that aspect missing. When i tested, the pages were displayed as if the css files were not present at all.

Though i tried by placing the css file in a different location  by thinking that whethere the relative path given by me would have got some mistakes, there was no luck still. Then i got a doubt and referred the Help section of the IDE itself. You got to do a different work around for your css files to have effect.

Actually, the Netbeans IDE places (keeps its own references to) the css files in a separate location which is totally far away from your application’s root folder. You have to get that location and put it in the files whichever need the css links (in case of .html, .jsp files).

Steps to do that:

1. Select the particular .css file and Right click on it.

2. Click on either the ‘Copy XML Style’ or ‘Copy HTML Style’ based on the file types where you gonna link this .css file.It will copy the location of this .css file from the Netbean’s perspective into the Clipboard.

3. Now paste the copied text (actual reference to the .css file) in the appropriate place of the files needing this .css file.

In case of .html file, it would be in the ‘href’ attribute of ‘<link>’ element placed inside the ‘<head>’ element. In case of .xml files, place the reference after the XML prologue or header.

Really don’t know whether its purely based on the Netbeans IDE or the internally built-in Tomcat has some contribution towards this! Is this a bug in Netbeans? Yet to find out that 🙂

But somehow found this to get the css effects on pages with an overhead towards portability! If at all, i need to take the .war file and place it normal Tomcat itself, i may need to change the reference to the .css files referred everywhere right. Just to avoid that , i have made one common .jsp file where i have put this .css reference in <link> element and included this .jsp file in all the other .jsp files through include directive!