Search results for 'include'. 3 post(s) found.

  1. 2008/10/27 How to include file in JSP ?
  2. 2008/01/25 How to include Javascript from anonther ?
  3. 2007/10/16 How to include a file with error reporting ?
2008/10/27 14:01

How to include file in JSP ?


Just like ASP, or PHP, JSP is also allow to include for programmer by include function.
Here's the simple example.
<HTML>
<BODY>
Going to include hello.jsp...<BR>
<%@ include file="hello.jsp" %>
</BODY>
</HTML>
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2008/01/25 15:30

How to include Javascript from anonther ?


Actually there is such a function in PHP which function is "include".
It's very strong function.

But Javascript does not support such a function.

Here's the alternate method to do that.


To include javascript, following is using usually:

<script type="text/javascript" src="the_script.js"></script>


But above script is not available in Javascript so following is the alternate method to include another javascript.

the_another_javascript.js:

document.write( "<script type=\"text/javascript\" src=\"the_script.js\"></script>");

Isn't it simple ?

Actually the main logic above is writing script tag in the document.

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 03:53 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 12:45 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:43 delete

    moneyideas

2007/10/16 08:35

How to include a file with error reporting ?


Sometimes you want to be able to give some feedback if a PHP include has failed. Here is a version using the fopen command, which can search the include path.

<?php

$includefile="foo.php";
//using fopen to verify file. the third parameter triggers include_path search
$handle = fopen($includefile, "r", 1);
if ($handle) {
 fclose($handle);
    include ($includefile);
} else {
 echo "file: $includefile not found in path";
   echo "handle is: $handle";
}

?>


Here's another example much better simple than the above. As you can see, just add @ in front of the function you will use. By '@', the error message will be ignored. (not be shown)
<?php

@include "foo.php";

?>
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 05:40 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 14:09 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:42 delete

    moneyideas