Wednesday, March 18, 2009

Paint Thinner Recycler



Often you work with technical problems or situation that should not be in the program flow, with runtime exceptions (unchecked exceptions). Some general information around the topic are presented in the following article nicely: http://www.roseindia.net/java/exceptions/exception.shtml .
Unchecked Exceptions must therefore can not be intercepted in the Struts Action. The Struts Framework processes in this case, the exception.

Struts in order to catch exceptions may generally be in the struts.xml set a global exception mapping. It can then be set as a global result:

\u0026lt;global-results> \u0026lt;result name="
error

"> / WEB-INF/web/jsp/error.jsp \u0026lt;/ result>

\u0026lt;/ global-results> \u0026lt; global-exception-mappings >
\u0026lt;exception-mapping exception="
java.lang.Exception
"result="error"/>

\u0026lt; ; /

global-exception-mappings

>   

The error.jsp can then print an error message, for example, as follows:


...

 \u0026lt;h1> ERROR \u0026lt;/ h1>  \u0026lt;s:actionerror/> 
\u0026lt;p> \u0026lt;s:property value="%{ exception.message} "/> \u0026lt;/ p> ;
\u0026lt;hr/>
\u0026lt;h3> Technical Details \u0026lt;/ h3>
\u0026lt;p>

\u0026lt;font style="font-size: 9px; color:gray">

\u0026lt;s: property value = "% {
exception stack}

"/>

\u0026lt;/ font is>
\u0026lt;/ p>

...

The exception then represented only in the client (browser). But it is important of course, the error message in document log files to operate then a root cause analysis.
make this centrally To be able to offer the global

error.jsp

. With the following commands Strack trace using log4j is logged.


.. .

 \u0026lt;% @ page import = "org.apache.log4j.Logger"%>  s \u0026lt;: set name = "StackTrace  
"value = '% {} exception stack " scope = "page" />
\u0026lt;%
String StackTrace = (String) pageContext.getAttribute (
StackTrace "); Logger.getLogger (
this . getClass ()) error (stack trace). %>
...
exception stack in variable on the value stack, the Struts Framework purely written the stack trace already The rest of the code should be substantially self-explanatory
..


0 comments:

Post a Comment