locale strings in struts

Discussion in 'Java' started by Mike Mayer, Apr 13, 2004.

  1. Mike Mayer

    Mike Mayer Guest

    I'm having two problems with trying to read strings out of struts config
    files. My google skills must be out of whack, because this should be easy
    enough to find :)

    First problem:
    I'm trying to read a param in web.xml. Here's a snippet of the web.xml and
    the code I am using to try to read the value. Does this look like I'm on the
    right track? Because smtpServer is null...


    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>mailServer</param-name>
    <param-value>smtp.mydomain.com</param-value>
    </init-param>
    ....

    public class MyAction extends Action {

    void someMethod() {
    ServletContext context = this.getServlet().getServletContext();
    String smtpServer = context.getInitParameter("mailServer");
    }
    }


    Second problem:
    Trying to use "locale" strings in ApplicationResources.properties files. I
    know I can define one, and get to it with the struts ActionMessage or the
    jsp tag <bean:write >. How can I get the value and read it into a string in
    my action class.
    e.g.: (in an Action class)
    void someMethod() {
    String messageSubject = // read from ApplicationResources.properties
    }


    Thanks in advance
    Mike Mayer
     
    Mike Mayer, Apr 13, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maurice Hulsman
    Replies:
    1
    Views:
    2,241
    Guus Bosman
    Jul 25, 2004
  2. Steve Sobol
    Replies:
    2
    Views:
    746
    Steve Sobol
    Sep 3, 2004
  3. Replies:
    0
    Views:
    2,444
  4. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    1,115
    Malcolm
    Jun 24, 2006
  5. Replies:
    4
    Views:
    1,355
  6. zade
    Replies:
    1
    Views:
    939
    James Kanze
    Mar 5, 2010
  7. Sibylle Koczian
    Replies:
    2
    Views:
    1,388
    Sibylle Koczian
    Nov 20, 2010
  8. Masao Mutoh
    Replies:
    0
    Views:
    225
    Masao Mutoh
    Dec 4, 2008
Loading...