File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

runtime exceptions

 
bharath phatak
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying handle the runtime exceptions globally throughout the application. I am using struts 1.1, I did the following changes in web.xml
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/error.jsp</location>
</error-page>

Also tried having the fix in struts-config.xml
<global-exceptions>
<exception type=" java.lang.RuntimeException "
key="sample.key"
path="/error.jsp"/>
</global-exceptions>

But Whenever the runtime exception(like javax.servlet.jsp.JspException) occurs the error.jsp is not getting displayed instead the entire stacktrace is shown which should be avoided. Please suggest what is going wrong or if there is any other solution to avoid the stacktrace shown on UI.

Any help is much appreciated
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope your error.jsp has its page attribute isErrorPage set to true
 
bharath phatak
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the error.jsp has the following attribute <%@ page isErrorPage="true" contentType="text/plain"%>.

Should i be setting any other value?

Thanks.
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bharath phatak wrote:Yes the error.jsp has the following attribute <%@ page isErrorPage="true" contentType="text/plain"%>.

Should i be setting any other value?

Thanks.


...and the page attribute errorPage is having value error.jsp on the jsp where the Exception object is getting created
 
bharath phatak
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the exception is thrown in sample.jsp, then should we have this line in the jsp <%@ page errorPage="/error.jsp"%>.
There are many JSP's in the application, i dont want to touch all the JSP's ,
is there any other way handle the exceptions without touching upon all the JSP's in struts 1.1
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bharath phatak wrote: If the exception is thrown in sample.jsp, then should we have this line in the jsp <%@ page errorPage="/error.jsp"%>.
There are many JSP's in the application, i dont want to touch all the JSP's ,
is there any other way handle the exceptions without touching upon all the JSP's in struts 1.1


I am not very sure about Struts 1.1 Bharath but the configuration you have done in the struts-congfig.xml seems to be right only I feel you should define action for all Jsp's as well...
 
bharath phatak
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks anyways.

hope i get a solution in this forum.
 
bharath phatak
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashutosh,
If we have to include <%@ page errorPage="/error.jsp"%>. and <%@ page isErrorPage="true" contentType="text/plain"%>. , then we should not make any changes to web.xml or struts-config.xml?
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bharath phatak wrote:Ashutosh,
If we have to include <%@ page errorPage="/error.jsp"%>. and <%@ page isErrorPage="true" contentType="text/plain"%>. , then we should not make any changes to web.xml or struts-config.xml?


I think so... but I may be wrong, you better try that out and let me know as well.
 
bharath phatak
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure. I will try and let you know
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic