java bean initialize values

P

polpot

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top