Sunday, November 22, 2009

JSTL tag not working in Weblogic Portal 10

Problem: JSTL complex expressions are not recognized in weblogic portal version 10 and onwards. It complains that cannot resolve the complex expressions and throws jsp compilation errors as follows:

Caused by: weblogic.servlet.jsp.CompilationException: Failed to compile JSP /package/JSPName.jsp
JSPName.jsp:165:13: Static attribute must be a String literal, its illegal to specify an expression.

Resolution: Replace the jstl taglib as http://java.sun.com/jsp/jstl/core for weblogic 10 and newer versions, for older versions it should be http://java.sun.com/jstl/core, jsp word is the key in the url for the taglib.

Junit test cases in Weblogic Workspace

How to run Junit from Weblogic Workspace without actually adding the library refrences from weblogic system libraries?

Open the project properties, build path and

1. Remove the following libraries from your Weblogic System Libraries

api.jar
wls-api.jar
weblogic.jar
wlcommons-logging.jar
junit.jar
wseeclient.jar

2. Add the following to the build path as external jar files
api.jar
wls-api.jar
weblogic.jar
wlcommons-logging.jar
junit.jar
wseeclient.jar
3. Compile the project and run the junit tests.

4. Thats it!

Not able to configure SAML

SAMLAuthenticator is not recognizing the alias and passphrase

Sometimes the way weblogic server is started, it does not recognize the DemoIdentity.jks and thats why we need to make the following changes to recognize this by weblogic server:

Go to weblogic admin console
Environment -> servers -> AdminServer -> Configuration -> Keystores
- change the value of Keystores to use “Custom Identity and Java Standard Trust”
- Enter the complete path of the DemoIdentity.jks in custom identity store field

Save the changes and redefine the SAMLAuthenticator.

Add proxy information to Server

Add the followings in the weblogic startup script to add the proxy configuration:

-Dhttp.proxyHost=[http-proxy-host-url]

-Dhttps.proxyHost=[https-proxy-host-url]

-Dhttp.proxyPort=[proxy-port]

-Dhttps.proxyPort=[ssl-port]

HttpConnectionURL Vs SoapHttpConnectionURL

How to make weblogic server to use HttpConnectionURL and not the SoapHttpConnectionURL (by default weblogic uses its own handler and thus creates the SoapHttpConnectionURL and not the HttpConnectionURL)?

Add the following in the startup script:

set JAVA_OPTIONS=%JAVA_OPTIONS% -DUseSunHttpHandler=true

EJB Client generation

EJB Client generation using workspace IDE

- Right click the ejb project – > Properties -> Weblogic EJB – > Jar Settings EJB Client Jar: enter the name of the client jar
- To build the client jar export the project as “EJB Jar File”, both the jars will be created, client as well as ejb jar.

EJB Client generation using ANT

- Add this @JarSettings(ejbClientJar = “xyzManagementClient.jar”) to the bean
- add desired EJBC flags directly to the build script where “weblogic.ejbc” is executed.

Wednesday, July 9, 2008

Window close in firefox

window.open(’javascript:window.close();’,'_self’,'’);

Suppress IE window closing message

When clicked IE displays the message "The web page you are viewing is trying to close the window. Do you want to close this window".

Javascript code

<script language="javascript">
function close_me()
{
window.opener = top;
window.close()
}
</script>

Thursday, July 3, 2008

Javascript - Truncate text after certain number of charecters

Here is the peice of javascript code which can be used to truncate all the texts in a HTML page after certain number of charecters:

function truncateText(tagid, size)
{
var allTdElements = document.getElementsByTagName('td');
for(var j=0; j < allTdElements.length ; j++)
{
var tempTdData = '';
var lineSeparator = '<BR>';
if (allTdElements[j].id == tagid)
{
var tdData = allTdElements[j].childNodes[0].innerHTML;
var arrayOfStrings = tdData.split(lineSeparator);

for (var k=0; k < arrayOfStrings.length; k++)
{
if(arrayOfStrings[k].length > size)
{
if(tempTdData.length > 0)
tempTdData += lineSeparator + arrayOfStrings[k].substr(0,size) + '...';
else
tempTdData += arrayOfStrings[k].substr(0,size) + '...';
}
else
{
if(tempTdData.length > 0)
tempTdData += lineSeparator + arrayOfStrings[k].substr(0,size);
else
tempTdData = tempTdData + arrayOfStrings[k].substr(0,size);
}
}

allTdElements[j].childNodes[0].innerHTML = tempTdData;
}
}
}