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

What are pull and push mvc architecture and which architecture does struts2 follow?

599


What is action chaining ?

734


What is the purpose of global-forwards tag in struct-config.xml?

664


How can we work with error tags?

638


When should be opt for struts framework?

677






What helpers in the form of jsp pages are provided in struts framework?

626


What applications use apache struts?

583


How is the mvc design pattern used in struts framework?

592


How is token generated?

634


What are the action classes in struts?

609


How can we get Servlet API Request, Response, HttpSession etc Objects in action classes?

704


What does i18n interceptor?

676


What is the purpose of @emailvalidator annotation?

583


What is the purpose of @key?

669


What is interceptor? And life cycle methods of interceptor?

655