Pages

Monday, November 9, 2009

How to Check Jar File Version

To have access to the version of a jar file, you should have access to the jar file. Precisely, you need to take a look at the jar file's manifest.

In case of the J2EE application

String checkjarFilevesion() {
try {
if(logger.isInfoEnabled())
logger.info("Verifying Jar Version");
String jarFilePath = Thread.currentThread().getContextClassLoader().getResource("../lib/javax.jar").getPath().replaceAll("%20", " ").toString();
JarFile jarfile = new JarFile(jarFilePath);
//Implementation-Version: 3.2.6.SP1
Manifest manifest = jarfile.getManifest();
String version = manifest.getMainAttributes().getValue("Implementation-Version");
return version;
} catch (IOException e) {
// TODO Auto-generated catch block
if(logger.isInfoEnabled())
logger.info("Invalid JAR file path");
}
return null;
}

Thursday, November 5, 2009

Absolute Path in J2EE Application


String jarFilePath = Thread.currentThread().getContextClassLoader().getResource("../lib/javax.jar").getPath().replaceAll("%20", " ");

Wednesday, April 22, 2009

Submitting Get request as POST using Javascript - DOM

function dynamicSubmitForm(link)
{
var myURL = link.split('?');
var formObj = document.createElement("form");
formObj.name = "KTDynaForm";
formObj.id = "KTDynaForm";
formObj.action = myURL[0];
formObj.method = "POST";
formObj.setAttribute("style", "display:none;");
if(myURL[1]!=null)
{
var urlArguments = myURL[1].split('&');
for(var i=0;i<urlArguments.length;i++)
{
var actionString = urlArguments[i].split("="); var inputObj = document.createElement("input");
inputObj.type = "hidden";
inputObj.value = actionString[1];
inputObj.name = actionString[0];
formObj.appendChild(inputObj);
}
}


document.body.appendChild(formObj);
formObj.submit();
return true;
}