Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do I catch errors globally, log them and show user an error page in J2EE app
    primarykey
    data
    text
    <p>I have searched this topic on google a bit and seen some best practices. But I need some specific advice. I am working on a J2EE app that has servlets/Struts2/Call to DAO's from JSP's. So the app is all kinds of messed up. Most of the data is fetched via stored procedures, which are being called by iBatis ORM/Spring. Sometimes when an error happens on the SP side it will display an ugly message to the user such as below:</p> <pre><code>javax.servlet.ServletException: org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in debtowed.xml. --- The error occurred while applying a parameter map. --- Check the debtowed.getFormerTenantData. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: ORA-06550: line 1, column 11: PLS-00905: object package.GET_FORMER_ADDRESS is invalid ORA-06550: line 1, column 7: PL/SQL: Statement ignored Caused by: java.sql.SQLException: ORA-06550: line 1, column 11: PLS-00905: object package.GET_FORMER_ADDRESS is invalid ORA-06550: line 1, column 7: PL/SQL: Statement ignored </code></pre> <p>At this point the above information is displayed in the browser and logged to server.log.<br> However, I want to do following:</p> <ul> <li>Present user with custom error page</li> <li>log the errors in myapp.log instead of server.log (we do this in some other places as we use log4j)</li> </ul> <p>Plese tell me what is the best way of doing this? Should I be adding something in web.xml? like a listener? will that be the only change or will I have to change existing code?</p> <p>The code does not do any error checking. it just calls the SP like below</p> <pre><code>getSqlMapClientTemplate().queryForList("sp.getfmrAddy", paramMap); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload