JDev

Code, javascriptMay 29, 2007 1:51 pm

You can’t set the float propety directly, like other properties, e.g. element.style.fontSize= "small";

One needs to use cssFloat for standard-compliant browsers, and styleFloat for Internet Explorer.

Simply set both of them. It will not cause any problems, and will work in all possible browsers.

    element.style.cssFloat = "right";
    element.style.styleFloat = "right"
;

Code, javascript 12:45 pm

Here is a function that returns the current date in JavaScript in the following format : May 29, 2007

function getCurrentDate(){
        var months = new Array(’January’,'February’,'March’,'April’,'May’,
            ‘June’,'July’,'August’,'September’,'October’,'November’,'December’);
        var date = new Date();
        var month = date.getMonth();
        return months[month] + " "+ date.getDate() +" , "+ date.getFullYear();
 }

 

javascriptMay 28, 2007 12:42 pm

I wrote a tutorial that shows how to build two select boxes in JavaScript where values in the one depend on the value in the other.

Code, regexMay 17, 2007 7:50 pm

  [-a-z\d]   -  a character class that matches a hyphen, letter, or digit

Some metacharacters:  
 
    \   Escape the next metacharacter
    ^   Match the beginning of the line
    .   Match any character (except newline)
    $   Match the end of the line (or before newline at the end)
    |   Alternation
    ()  Grouping
    []  Character class

 Quantifiers:

    *      Match 0 or more times
    +      Match 1 or more times
    ?      Match 1 or 0 times
    {n}    Match exactly n times
    {n,}   Match at least n times
    {n,m}  Match at least n but not more than m times

 

Code, apacheMay 16, 2007 5:31 pm

To enable url rewriting on a per-directory basis, you need to use an .htaccess file that should be located in the directory used for url
rewriting.

In the .htaccess file, type: 

Options FollowSymLinks
RewriteEngine On

Then use the RewriteRule directive, e.g:

RewriteRule ^oldname.php$ /subsite/newname.php [R] 

A very basic mod_rewrite tutorial is located at http://www.webmastertips.us/tutorials/mod_rewrite.htm 

 However, there is an important detail missing from the tutorial - make sure the <Directory…> container in the httpd.conf file contains the following directive:

 AllowOverride All

If AllowOverride is set to None, no url rewriting will take place. 

Also, do not forget to uncomment the LoadModule rewrite_module modules/mod_rewrite.so directive in the httpd.conf file.

Code, apacheMay 11, 2007 2:07 pm

For creating .htaccess, don’t create it inside Explorer. Open Notepad, type something and SAVE AS “.htaccess” and choose the file type as “ALL FILES”.

From http://sniptools.com/tutorials/windows-apache-and-htaccess-authentication 

Code, javascriptMay 10, 2007 1:15 pm

 <a href="#" onClick="callFunction();return false;"> Text Link </a>

For explanations go to http://forwardlogic.net/dev/javascript_tips.php

Code, jstlMay 9, 2007 12:12 pm

To get session values in JSTL, use the following piece of code:

<c:forEach items="${sessionScope}" var="par">
        Session object name/value : <c:out value="${par.key} - ${par.value}"/>
</c:forEach>

 To find out how to sort session or request parameters, visit http://www.ekcsoft.com/coding/java/jstl_parameters  

JSTL Books on Amazon.com 


 
Code, php, javaMay 3, 2007 6:00 pm

I always have trouble remembering the correct arguments to the substring() method in order to delete the last character in a String.

Here is how you do it in Java: 

str =  str.substring(0, str.length()-1);

A similar statement in PHP:

$str = substr($str,0, strlen($str)-1); 

 

 More Java tips at http://www.ekcsoft.com/coding/java

Code, java 5:15 pm

Apparently, you cannot continue a long string on multiple lines with a \ separator like you do it in C or JavaScript.

Can’t be done. Gotta use the plus sign or append() to a StringBuffer. So the post title is actually misleading.