How to set email notification using struts.Plz give the
example code?

Answer Posted / anas

Solution is to implement an email notification system. The
notification system will generate an email message whenever
the application detects an error. If you are already using
a standard logging framework like log4j.

import java.util.logging.*;
public class JDKLoggingExample
{
private static final Logger log =
Logger.getLogger(JDKLoggingExample.class.getName());
public static void main(String[] args)
{
try
{
log.fine("This is a fine message.");
int i = Integer.parseInt("Hello world");
}
catch (java.lang.Exception ex)
{
log.log(Level.SEVERE, "Caught an exception",
ex);
}
}

---------------------------------------------------------

import org.apache.log4j.*;

public class Log4jExample
{

private static final Logger log =
Logger.getLogger(Log4jExample.class);

public static void main(String[] args)
{
try
{
log.debug("This is a debug message.");
int i = Integer.parseInt("Hello world");
}
catch (java.lang.Exception ex)
{
log.error("Caught an exception", ex);
}
}
}

Is This Answer Correct ?    3 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How are interceptors and servlet filters different?

681


What are the contents on web.xml in struts application ?

701


What are the components of struts framework?

771


Why struts 1 classes are not thread safe whereas struts 2 classes are thread safe?

679


What is the purpose of constant tag in struts.xml?

701


What is the difference between plain-validator and field-validator?

704


What are the 5 constants of action interface?

757


What is the use of struts?

696


What is struts.devmode?

769


What are the reasons for an error message not being displayed while developing struts application?

716


Is struts 1 still supported?

672


What is the use of token interceptor in Struts2?

822


What is the purpose of @key annotation annotation?

801


What are inner class and anonymous class?

722


Difference between struts and spring?

757