Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

handle exception programmaticaly??

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello rancher,

I am curious to know if there is some way to handle generated exception programmaticaly?? Other then specifying a <error-page> element in the web.xml.
And how it works, if there is any API mapped to it please let me know.


Thnaks in Advance
 
ankit kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
yes you can by <c:catch > . i think. HFSJ 473
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not JSTL... Is there any other methods in API. using<c:catch> has some limitations.
 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is in POJO you can just use

try{
}catch(Exception e){
}

If it is in JSP you can forward it to some user defined page!

<c:if test="${empty parm.userName}">
<jsp:forward page="handleIt.jsp">
<jsp:param name="from" value="ELJsp.jsp" />

</jsp:forward>
</c:if>


Or
While handling business exceptions programatically using a RequestDispatcher
one or more of following attributes would you set in the request
1) javax.servlet.error.status_code
2) javax.servlet.error.exception_type
3) javax.servlet.error.message
4) javax.servlet.error.exception

why ?
An error handler servlet should have access to 4 attributes:
1) javax.servlet.error.status_code
2) javax.servlet.error.exception
3) javax.servlet.error.servlet_name
4) javax.servlet.error.request_uri

So, if you are forwarding the request to an error handling servlet manualy using RequestDispatcher,
you should set the above attributes in the request before forwarding the request to the servlet.

javax.servlet.error.exception_type
and
javax.servlet.error.message
are basically redundant because these can be derived from the javax.servlet.error.exception attribute which contains the exception object.


Thanks
AR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic