Monday, March 26, 2007

Using EL in custom tags as attributes

Problem:
I was working on a custom tag and i needed to pass it a bean from a JSP page kind of like this:
<customtag var="${somebean.something.else}">
I realized that what i was getting inside my custom tag was a String, not my bean.

Solution:
You need to use the ExpressionEvaluator to evaluate the expression, and get the bean, here is the code i used in my SimpleTag: (i was getting a Date object by the way)




Edit Aug 7, 2008:
It has come to my attention that in jsp 2.0 the EL expressions are evaluated before being passed to the custom tags, so you dont need to do any of this crap anymore.

Tuesday, March 20, 2007

how to make .so files load in unix

Ive had this problem too many times and so i should blog the solution. The problem usually looks something like this: You try to run something and you get an error screaming about failing to load some file ending in .so

example:

failed: Can't load '/app/teamsite/iw-perl/site/lib/auto/DBD/Oracle/
Oracle.so' for module DBD::Oracle: ld.so.1: perl: fatal: libnnz10.so: open failed: No such
file or directory at /app/teamsite/iw-perl/lib/DynaLoader.pm line 229.

solution:

All these .so problems seem to be have a common solution. You need tell unix where to look for your libraries. This is how you do it.
  1. Figure out where your application has its .so files. Usually this is in a directory called lib, and it usually contains more then one .so file.
  2. You need to become root, and run this command:
  3. crle
  4. write down everything which is output, because if you break things you will need to go back to this. On solaris 10 this is the important piece which has to always be in the output: Default Library Path (ELF): /usr/lib
  5. Now we need to add our library locations to the Default Library Path, run this as root:
  6. crle -c /var/ld/ld.config -l /usr/lib:/your/directory/where/the/so/files/are
  7. exit root
Now try to run your application and see if it runs. If it does not run then it may complain about another .so file in another directory which you missed. You will need to add it to the end of the path in step 5 like this:
crle -c /var/ld/ld.config -l /usr/lib:/your/directory/where/the/so/files/are:/another/lib/path

Important: if you remove the /usr/lib part from the Default Library Path, shit will hit the fan.
Use this at your own risk.

Wednesday, March 14, 2007

Flash in IE6 xml compression problem

Problem:

There seems to be a problem with flash player running on IE6 loading XML files from a web server which has compression enabled. It seems like the XML is never decompressed correctly, so whatever flash that is using it breaks. Everything seems to work fine if you use firefox or IE7 to access the same flash swf. I found one page talking about this problem, right here:

http://blog.mediacatalyst.com/pivot/entry.php?id=281

Solution:

First let me say, that on our servers the XML was generated by a JSP, so i had a bit more control over html headers and such. This is what i did to solve this problem:
  1. Set Cache-Control HTML header to nothing ("")
  2. Set Pragma HTML header to nothing
  3. Make sure that the XML file had the XML declaration as the very first thing in the file
  4. Set the JSP page content-type to text/xml

Thursday, March 08, 2007

How to backup firefox plugins

I needed to back up my plugins to install the DOM inspector, which requires a firefox reinstall. Here is how to back up the firefox plugins:

C:\Documents & Settings\USERNAME\Application Data\Mozilla\Firefox\Profiles\
there are directories in there
copy those out to save them
then.... after you reinstall, copy them back and run "firefox -profilemanager"
and create a "NEW" profile using the directory you just copied

It works cross platform also... put the stuff on a jumpdrive and have the same profile in Linux and Windows

source: www.jacobsylvia.com