PHP absolute path to root

Create a constant with absolute path to the root by using define in ShowInfo.php: define(‘ROOTPATH’, __DIR__); Or PHP <= 5.3 define(‘ROOTPATH’, dirname(__FILE__)); Now use it: if (file_exists(ROOTPATH.’/Texts/MyInfo.txt’)) { // … } Or use the DOCUMENT_ROOT defined in $_SERVER: if (file_exists($_SERVER[‘DOCUMENT_ROOT’].’/Texts/MyInfo.txt’)) { // … }

Wrong extraction of .attr(“href”) in IE7 vs all other browsers?

It’s certainly not a bug in jQuery but instead browsers’ inconsistent implementations of .getAttribute(‘href’) – I suggest using just .get(0).href for consistency. Seems like you can access the attribute text in IE and Mozilla using .get(0).getAttribute(‘href’, 2) if you don’t want the absolute URI. Note however this won’t work in Opera and I haven’t tested … Read more

Get path of Android resource

Use URI Paths instead of “absolute” path, see this post Uri path = Uri.parse(“android.resource://com.segf4ult.test/” + R.drawable.icon); Uri otherPath = Uri.parse(“android.resource://com.segf4ult.test/drawable/icon”); Or use openRawResource(R.id) to open an inputStream, and use it the same way you would use a FileInputStream (readonly)

How to find the working folder of a servlet based application in order to load resources

You could use ServletContext#getRealPath() to convert a relative web content path to an absolute disk file system path. String relativeWebPath = “/WEB-INF/static/file1.ext”; String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath); File file = new File(absoluteDiskPath); InputStream input = new FileInputStream(file); // … However, if your sole intent is to get an InputStream out of it, better use ServletContext#getResourceAsStream() instead … Read more