You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "O. Oke" <re...@yahoo.co.uk> on 2004/08/28 19:39:18 UTC

ExceptionHandler handles, but no error output in JSP

Help please!

I have just integrated ExceptionHandler.  It now
appears to handle exceptions (because stack trace is
no longer displayed in browser, when there is an
error) but no error is output in JSP
My jSP (TILES) has tags for actionErrors and
ActionMessages, which outputs errors/messages for
ohter things, but does not work for ExceptionHandler
error.

Can anyone please tell me why exceptionHandler errors
are not output in my JSP screen?

Please see my source code below.

Thank you.


The Struts config setting:
=========================

<global-exceptions>
   <exception
      
handler="com.fujimitsu.cargo.exception.CargoExceptionHandler"
       key="global.db.sql.exception"
       path=".customerDef.jsp"
       scope="request"
       type="java.sql.SQLException"/>
</global-exceptions>


Properties file
===============
global.db.sql.exception=The SQL exception below was
raised:



HANDLE
======
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.config.*;
import org.apache.struts.Globals;

public class CargoExceptionHandler extends
ExceptionHandler {
   public ActionForward execute( Exception ex,
                              ExceptionConfig
exConfig,
                              ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest
request,
                              HttpServletResponse
response
  ) throws ServletException{



      ActionError error =  new ActionError
(exConfig.getKey (), ex.getMessage ());

      ActionForward forward =
mapping.getInputForward();
      String property = ActionErrors.GLOBAL_MESSAGE;
      String scope = exConfig.getScope();

      storeException (request, property, error,
forward, scope);
      ex.printStackTrace (System.err); // should log
      request.setAttribute ("ex", ex);
      //return forward;

        return (new
ActionForward(mapping.getInput()));
      //return new ActionForward(exConfig.getPath());
   }
}




aCTION ERROR/MESSAGES tiles...
==============================
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<logic:messagesPresent message="false">
<TR>
<TD class="error" colspan="3">
   <UL>
   <html:messages id="error" header="errors.header"
footer="errors.footer">
      <LI><bean:write name="error"/></LI>
   </html:messages>
   </UL>
</TD>
</TR>
</logic:messagesPresent>
<logic:messagesPresent message="true">
<TR>
<TD class="message" colspan="3">
   <UL>
   <html:messages id="message" message="true"
header="messages.header" footer="messages.footer">
      <LI><bean:write name="message"/></LI>
   </html:messages>
   </UL>
</TD>
</TR>
</logic:messagesPresent>



	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ExceptionHandler handles, but no error output in JSP(tiles)

Posted by "O. Oke" <re...@yahoo.co.uk>.
 --- Michael McGrady <mi...@michaelmcgrady.com> wrote: 
> O. Oke wrote:
> 
> >Help please!
> >
> >I have just integrated ExceptionHandler into
> >struts-config.xml file.  It now
> >appears to handle exceptions (because stack trace
> is
> >no longer displayed in browser, when there is an
> >error) but no error is output in JSP.
> >My jSP (TILES) has tags for actionErrors and
> >ActionMessages, which outputs errors/messages for
> >other things such as validation errors, but does
> not
> >work for ExceptionHandler in struts-config.xml
> file.
> >
> >Can anyone please tell me why exceptionHandler
> errors
> >are not output in my JSP(tiles) screen?
> >
> >Please see my source code below.
> >
> >Thank you.
> >
> 
> I just had the thought that this whole way of doing
> things may be 
> superior to logging with respect to debugging. 
> Hmmm?
> 
> Michael
> 


Michael,

I do intend to log the error and will add the
functionality to do that later.  My primary concern
for now is to give the user some information.  My
problem is what additional step to take in order to
output the message on the screen - JSP (TILES).

Thank you.

Ola.



	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ExceptionHandler handles, but no error output in JSP(tiles)

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
O. Oke wrote:

>Help please!
>
>I have just integrated ExceptionHandler into
>struts-config.xml file.  It now
>appears to handle exceptions (because stack trace is
>no longer displayed in browser, when there is an
>error) but no error is output in JSP.
>My jSP (TILES) has tags for actionErrors and
>ActionMessages, which outputs errors/messages for
>other things such as validation errors, but does not
>work for ExceptionHandler in struts-config.xml file.
>
>Can anyone please tell me why exceptionHandler errors
>are not output in my JSP(tiles) screen?
>
>Please see my source code below.
>
>Thank you.
>

I just had the thought that this whole way of doing things may be 
superior to logging with respect to debugging.  Hmmm?

Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


ExceptionHandler handles, but no error output in JSP(tiles)

Posted by "O. Oke" <re...@yahoo.co.uk>.
Help please!

I have just integrated ExceptionHandler into
struts-config.xml file.  It now
appears to handle exceptions (because stack trace is
no longer displayed in browser, when there is an
error) but no error is output in JSP.
My jSP (TILES) has tags for actionErrors and
ActionMessages, which outputs errors/messages for
other things such as validation errors, but does not
work for ExceptionHandler in struts-config.xml file.

Can anyone please tell me why exceptionHandler errors
are not output in my JSP(tiles) screen?

Please see my source code below.

Thank you.


The Struts config setting:
=========================

<global-exceptions>
   <exception
      
handler="com.fujimitsu.cargo.exception.CargoExceptionHandler"
       key="global.db.sql.exception"
       path=".customerDef.jsp"
       scope="request"
       type="java.sql.SQLException"/>
</global-exceptions>


Properties file
===============
global.db.sql.exception=The SQL exception below was
raised:



HANDLER
=======
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.config.*;
import org.apache.struts.Globals;

public class CargoExceptionHandler extends
ExceptionHandler {
   public ActionForward execute( Exception ex,
                              ExceptionConfig
exConfig,
                              ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest
request,
                              HttpServletResponse
response
  ) throws ServletException{



      ActionError error =  new ActionError
(exConfig.getKey (), ex.getMessage ());

      ActionForward forward =
mapping.getInputForward();
      String property = ActionErrors.GLOBAL_MESSAGE;
      String scope = exConfig.getScope();

      storeException (request, property, error,
forward, scope);
      ex.printStackTrace (System.err); // should log
      request.setAttribute ("ex", ex);
      //return forward;

        return (new
ActionForward(mapping.getInput()));
      //return new ActionForward(exConfig.getPath());
   }
}




ACTION ERROR/MESSAGES in tiles...
=================================
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<logic:messagesPresent message="false">
<TR>
<TD class="error" colspan="3">
   <UL>
   <html:messages id="error" header="errors.header"
footer="errors.footer">
      <LI><bean:write name="error"/></LI>
   </html:messages>
   </UL>
</TD>
</TR>
</logic:messagesPresent>
<logic:messagesPresent message="true">
<TR>
<TD class="message" colspan="3">
   <UL>
   <html:messages id="message" message="true"
header="messages.header" footer="messages.footer">
      <LI><bean:write name="message"/></LI>
   </html:messages>
   </UL>
</TD>
</TR>
</logic:messagesPresent>




	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org