Archive for the ‘html’ Category

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!

opening the html file inside an archive

Have you tried opening a HTML file which is present inside an archive file say for example a .zip file in Windows OS?

In Windows XP, it allows you to just open and see the contents of a zip file directly without using an extractor (WinZip etc), as if it was a normal folder. In such case, you may get access to the files present in the zip file (archive).

When you open a HTML file inside the archive, and if in case the html file contains some images, the images will not be displayed in the opened HTML file. You may wonder why it does not display the images though the images being referred are present in an appropriate folder for images alone (say a directory named “images” which is the traditional way)!!

The reason is, though you have opened the HTML file from an archive directly, the opened HTML file is alone opened and NOT the files/images present in the other directories. That’s why the images are not properly displayed.

Solution

You need to extract the zip file using an extractor. Say, WinZip for an example. Once you extract, all the contents in a zip file will get extracted including images. Then when you open the HTML file, the opened HTML file will now have access to the images present in the appropriate folder (“images”) since that folder also is extracted and available.

Happened to help one of my colleagues when she asked me by saying the error. Thought of blogging it as well after explaining it to my colleague. 😉