servlet 인 int 되는 시점에서 공유 변수 설정을 하기 위해서
System.setProperty 를 이용해서 값을 저장후 서블릿 단에서 getProperty 를 통해서 호출 한다..
게시판 구현시 dbcp접속 servlet이 int되는 시점에서
dbType을 저장 하는데 활용 했음 .
setProperty
public static String setProperty(String key,
String value)
- Sets the system property indicated by the specified key.
First, if a security manager exists, its SecurityManager.checkPermission
method is called with a PropertyPermission(key, "write")
permission. This may result in a SecurityException being thrown. If no exception is thrown, the specified property is set to the given value.
-
- Parameters:
key
- the name of the system property.
value
- the value of the system property.
- Returns:
- the previous value of the system property, or
null
if it did not have one.
- Throws:
SecurityException
- if a security manager exists and its checkPermission
method doesn't allow setting of the specified property.
NullPointerException
- if key
or value
is null
.
IllegalArgumentException
- if key
is empty.
- Since:
- 1.2
- See Also:
getProperty(java.lang.String)
, getProperty(java.lang.String)
, getProperty(java.lang.String, java.lang.String)
, PropertyPermission
, SecurityManager.checkPermission(java.security.Permission)
getProperty
public static String getProperty(String key,
String def)
First, if a security manager exists, its SecurityManager.checkPermission
method is called with a PropertyPermission(key, "write")
permission. This may result in a SecurityException being thrown. If no exception is thrown, the specified property is set to the given value.
- Parameters:
key
- the name of the system property.value
- the value of the system property.- Returns:
- the previous value of the system property, or
null
if it did not have one. - Throws:
SecurityException
- if a security manager exists and itscheckPermission
method doesn't allow setting of the specified property.NullPointerException
- ifkey
orvalue
isnull
.IllegalArgumentException
- ifkey
is empty.- Since:
- 1.2
- See Also:
getProperty(java.lang.String)
,getProperty(java.lang.String)
,getProperty(java.lang.String, java.lang.String)
,PropertyPermission
,SecurityManager.checkPermission(java.security.Permission)
getProperty
public static String getProperty(String key,
String def)
- Gets the system property indicated by the specified key.
First, if there is a security manager, its
checkPropertyAccess
method is called with thekey
as its argument.If there is no current set of system properties, a set of system properties is first created and initialized in the same manner as for the
getProperties
method.- Parameters:
key
- the name of the system property.def
- a default value.- Returns:
- the string value of the system property, or the default value if there is no property with that key.
- Throws:
SecurityException
- if a security manager exists and itscheckPropertyAccess
method doesn't allow access to the specified system property.NullPointerException
- ifkey
isnull
.IllegalArgumentException
- ifkey
is empty.- See Also:
setProperty(java.lang.String, java.lang.String)
,SecurityManager.checkPropertyAccess(java.lang.String)
,getProperties()
public static String getProperty(String key)
- Gets the system property indicated by the specified key.
First, if there is a security manager, its
checkPropertyAccess
method is called with the key as its argument. This may result in a SecurityException.If there is no current set of system properties, a set of system properties is first created and initialized in the same manner as for the
getProperties
method.- Parameters:
key
- the name of the system property.- Returns:
- the string value of the system property, or
null
if there is no property with that key. - Throws:
SecurityException
- if a security manager exists and itscheckPropertyAccess
method doesn't allow access to the specified system property.NullPointerException
- ifkey
isnull
.IllegalArgumentException
- ifkey
is empty.- See Also:
setProperty(java.lang.String, java.lang.String)
,SecurityException
,SecurityManager.checkPropertyAccess(java.lang.String)
,getProperties()
- Gets the system property indicated by the specified key.