java bean initialize values

Discussion in 'Java' started by polpot, May 18, 2004.

  1. polpot

    polpot Guest

    I kindly request your help
    I've a Javabean that i must declare only with session or request scope
    i have to initialize the variables with values taken from web.xml


    This is a sample situation
    file web.xml
    <param-name>state</param-name>
    <param-value>01</param-value>
    </context-param>
    <context-param>
    <param-name>county</param-name>
    <param-value>TO</param-value>
    </context-param>
    <context-param>
    <param-name>town</param-name>
    <param-value>01000011</param-value>
    </context-param>

    This is the bean
    import java.io.*;
    public class SearchBean implements Serializable
    {
    private String state;
    private String county;
    private String comune ;

    public String getState() {
    return state;
    }
    public void setState(String state) {
    this.state = state;
    }
    public String getCounty() {
    return county;
    }
    public void setCounty(String county) {
    this.county = county;
    }
    public String getTown() {
    return town;
    }
    public void setTown(String town) {
    this.town= town;
    }
    }
    I wish that state, county and town values in the bean will be initialized
    with web.xml values
    (ie. Private String regione =01 read from web.xml)
    The olny solution I found is to use System.properties (set in startup
    servlet and get in bean:
    state=System.getProperty("state"); etc.
    I don't want to use this bacause there are more parametrized applications in
    the same JVM and I think there will be data confusion.
    I can't initialize values in the JSP callin the bean because these will be
    default values (selected value) for combo boxes

    Any help will be greatly appreciated
     
    polpot, May 18, 2004
    #1
    1. Advertising

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. Benjamin Stewart

    To bean or not to bean...

    Benjamin Stewart, Jun 30, 2003, in forum: Java
    Replies:
    0
    Views:
    832
    Benjamin Stewart
    Jun 30, 2003
  2. David Thielen
    Replies:
    2
    Views:
    837
    Marek Lange
    Sep 12, 2003
  3. Markku Salminen
    Replies:
    3
    Views:
    5,894
    Michael Borgwardt
    Jan 21, 2004
  4. Takeshi
    Replies:
    0
    Views:
    549
    Takeshi
    Jan 28, 2004
  5. kumar
    Replies:
    1
    Views:
    580
    Wendy S
    Feb 13, 2004
Loading...

Share This Page