I would write a Struts Plug-In (very easy) and initialize the "smtpServer" variable (and similar variables) there, making the configured value available to the rest of the application (including your Actions) by setting an Application scope attribute (this also abstracts the configuration so that in the future you might configure it in a properties file or source file instead of web.xml).

For example:

form.getServlet().getServletContext().getAttribute("smtpServer");


Erik


Caroline Jen wrote:

We cannot put a method inside another method.

When using the Struts, we start with:

public final class MyClass extends Action
{
   public ActionForward execute( ActionMapping
mapping,
           ActionForm form,
           HttpServletRequest request,
           HttpServletResponse response )
       throws java.lang.Exception
   {

       .......
       .......

   }
}

I have a void init( ...) { ... } method shown below. Of course, I cannot put this init( ... ) inside the
ActionForward Execute( ... ) { ... }


What am I supposed to do?  Do I put this void init(
... ) { ... } method before the ActionForward Execute(
... ) { ... } begins?

Code:
=================================================
String smtpServer;
public void init(ServletConfig config) throws
ServletException
{
super.init(config);
smtpServer =
config.getInitParameter("smtpServer");
}
=================================================





__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to