'include'에 해당되는 글 3건

  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 toinclude 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
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 0 Comment 0
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 PHPinclude 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 0 Comment 0