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:
In JSP:
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'.
Trying to furnish my experiments with exceptions faced during J2EE, Struts, AS400, Crystal Report, AJAX development and also during Deployments. Most of them have been collected from websites, books, trail & error methods.Expecting a better way of solutions, suggestions from you.
Sunday, August 9, 2009
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+'
');
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. "
"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:
WebModule_
uses
where
is the generated WebModule value from META-INF/.modulemaps file for the war
is the name of the war project in the workspace
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:
where
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
Files\IBM\WebSphere\AppServer1\profiles\AppSrv01\logs\server1\startServer.log
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.
Solution:
In the logs folder for the server, (e.g. ...\profiles\app\logs\server1 )
there is a file called server1.pid, 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.
ADMU0116I: Tool information is being logged in file C:\Program
Files\IBM\WebSphere\AppServer1\profiles\AppSrv01\logs\server1\startServer.log
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.
Solution:
In the logs folder for the server, (e.g. ...\profiles\app\logs\server1 )
there is a file called server1.pid, 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.
jsp.error.attribute.null_name
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
Cause:
I found that in the .jsp, the key value in bean:message is missing double quotes.
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
Cause:
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:
java.io.NotSerializableException
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at com.ibm.CORBA.iiop.UtilDelegateImpl.wrapException(UtilDelegateImpl.java:696)
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at javax.rmi.CORBA.Util.wrapException(Util.java:296)
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at com.sit.app.ejb.ccf.ctltbl._CCCtlTbl_Stub.getBizNatCode(_CCCtlTbl_Stub.java:681)
[1/24/08 14:53:51:625 SGT] 00000028 SystemErr R at com.sit.app.ccf.ctltbl.actions.CCBizNatCodeAction.getBizNatCodeList(CCBizNatCodeAction.java:60)
Cause:
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.
Solution:
public class CCBank implements Serializable{
public String getXXX(){};
public void setXXX(){};
.............
..............
.............
}
CannotInstantiateObjectException
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: com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl
Reference Factory Class Location URLs:
Exception stack trace: com.ibm.websphere.naming.CannotInstantiateObjectException: 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
Cause:
As it explains clearly, trying to use servlet 2.3 under 2.2 dtd defintion.
Solution:
Replace Doctype declartion in web.xml
from
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: com.ibm.ejs.j2c.ConnectionFactoryBuilderImpl
Reference Factory Class Location URLs:
Exception stack trace: com.ibm.websphere.naming.CannotInstantiateObjectException: 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
Cause:
As it explains clearly, trying to use servlet 2.3 under 2.2 dtd defintion.
Solution:
Replace Doctype declartion in web.xml
from
DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc. //DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd" to DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc. //DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"
Subscribe to:
Posts (Atom)