Sunday, August 9, 2009

Print selected portions of your page by winow.print()

Step 1:

create print.css file:

// to ignore input elements, images
img, input, .errortext, .noprint {
display : none;

.toprint {
display : block;

// to print table with border,lines
table.tablestyle1 { border-collapse: collapse; }
table.tablestyle1 th, table.tablestyle1 td { border: 1px solid #888; }

// to provide page break
.break {
page-break-after : always;

Step 2:


Link the above css in JSP file.
link href="css/print.css" media="print" type=text/css rel=stylesheet

Use class name 'toprint' on those portions which you like to display it on 'Print Preview'.

Browser Detection in JavaScript [Code]

Here is the source code that performed the browser detection:

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName = '';
var fullVersion = 0;
var majorVersion = 0;

// In Internet Explorer, the true version is after "MSIE" in userAgent
if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
browserName = "Microsoft Internet Explorer";
fullVersion = parseFloat(nAgt.substring(verOffset+5));
majorVersion = parseInt(''+fullVersion);

// In Opera, the true version is after "Opera"
else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
browserName = "Microsoft Internet Explorer";
fullVersion = parseFloat(nAgt.substring(verOffset+6));
majorVersion = parseInt(''+fullVersion);

// In most other browsers, "name/version" is at the end of userAgent
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) { browserName = nAgt.substring(nameOffset,verOffset); fullVersion = parseFloat(nAgt.substring(verOffset+1)); if (!isNaN(fullVersion)) majorVersion = parseInt(''+fullVersion); else {fullVersion = 0; majorVersion = 0;} } // Finally, if no name and/or no version detected from userAgent... if (browserName.toLowerCase() == browserName.toUpperCase() || fullVersion==0 || majorVersion == 0 ) { browserName = navigator.appName; fullVersion = parseFloat(nVer); majorVersion = parseInt(nVer); } document.write('Browser name = '+browserName+'
document.write('Full version = '+fullVersion+'
document.write('Major version = '+majorVersion+'
document.write('navigator.appName = '+navigator.appName+'
document.write('navigator.userAgent = '+navigator.userAgent+'

java.lang.error - Unresolved Compilation problem

Solution from on of the developerWorks expert.

"Most of us have encounted this error when working with JSP pages. If JSP pages are compiled on the fly, then it is possible that errors are present in it that cannot be resolved at runtime. Hence it is a good idea to compile your JSPs as U develop them. Most of the modern IDE's have support for compiling JSP's during the 'build' process.

Recently I encountered the same error while building a web application on Netbeans. I was getting the "java.lang.error - Unresolved compilation problem" for a Struts Action class, that was referencing another bean. It was strange that this error was not caught by the compiler. I did a 'clean build' again and everything was OK. But still at runtime, I got the same error.
I was perplexed and could not understand what was the problem.
Then suddenly inbetween, I started getting ClassCastExceptions. It was then I reliazed that there was older classes in the classpath somewhere, that was messing things up.

Closer inspection revealed that someone had placed "classfiles" into source-control (VSS) and when we did 'get-latest', the old class files were also downloaded into our directory.

Moral of the story: Whenever U get ClassCastExceptions or Unresolved Compilation problems at runtime, check if U have stale class files somewhere in the classpath. "

IWAE0053E An internal error has occurred running validation on project. The deployment descriptor

Method 1

As suggested by another developerWorks page, I was able to fix it by:

1) Close the project (Right-click the project, Close Project)
2) Open the project (Right-click, Open Project)
3) Force a full rebuild

And, no, skipping straight to #3 didn’t fix the problem for me. But, these three steps did.

Method 2[Haven't tried this methos
This snippit that was posted to the IBM developer works forum :

I had the same problem, and resolved it by opening the .settings folder of the EAR project and editing the org.eclipse.wst.common.component file. The war module listed in the error message is missing as a dependent module, so I added it:


is the generated WebModule value from META-INF/.modulemaps file for the war
is the name of the war project in the workspace

ADMU7704E: Failed while trying to start the Windows Service associated with

Exception while starting Websphere server:

ADMU0116I: Tool information is being logged in file C:\Program
ADMU7701I: Because server1 is registered to run as a Windows Service, the
request to start this server will be completed by starting the
associated Windows Service.
ADMU7704E: Failed while trying to start the Windows Service associated with
server: server1;
probable error executing WASService.exe: Starting
Service: PG13Node01
Timed out waiting for service to respond to
command, after 60 seconds.Failed to start service, or timed out
while waiting for start to complete. Check the logs for details.


In the logs folder for the server, (e.g. ...\profiles\app\logs\server1 )
there is a file called, in this case, this file, contains the process id for the server process.
This file it's supossed to be deleted when the server shuts down, but when the server crash down, or when some 'unusual' situation happens the file is not deleted, then when the server is trying to start and find this file, it doesn't start and give some weird exceptions, I don't know why, because I checked and the process id in the file most of the time it's not used by the OS, anyway the server simply doesn't start.

so simply delete the file, and start the server.


Exception while using struts tag inside JSP.

00000031 ServletWrappe E SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: /webapp/jsp/Login.jsp. Exception thrown : java.lang.NullPointerException: jsp.error.attribute.null_name

I found that in the .jsp, the key value in bean:message is missing double quotes.

EJB Run time exception (at javax.rmi.CORBA.Util.wrapException)

[1/24/08 14:53:51:609 SGT] 00000028 SystemErr R java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.MarshalException: Exception occurred in server thread; nested exception is:
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at javax.rmi.CORBA.Util.wrapException(
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at

Here the getBizNatCodeList() method in Action class returns an ArrayList of Java Object. In my case , this java bean has not serialized. so by making the bean serialize using 'implements Serializable', we can avoid this error.


public class CCBank implements Serializable{

public String getXXX(){};

public void setXXX(){};



ConnectionFac E J2CA0106E: A 5.0 DataSource was attempted to be used in a WebModule that was not level 2.3.
W NMSV0605W: A Reference object looked up from the context "localhost/nodes/localhost/servers/server1" with the name "jdbc/client" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
Reference Factory Class Name:
Reference Factory Class Location URLs:

Exception stack trace: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is java.lang.Exception: Attempted to use a 5.0 DataSource outside of a 2.3 servlet

As it explains clearly, trying to use servlet 2.3 under 2.2 dtd defintion.


Replace Doctype declartion in web.xml

DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.
//DTD Web Application 2.2//EN"


DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.
//DTD Web Application 2.3//EN"