Reputation: 14125
I am trying to get JAVA_OPTS value defined in catalina.bat in a jsp file. Can someone tell me how to do that.
For Example: My JAVA_OPTS definition in catalina.bat is like
JAVA_OPS= -DMyProjectHome=D:\Projects
I want to have the value of MyProjectHome at run time in jsp file so I am trying to do is ${MyProjectHome} but it is doing nothing.
Or is there a way I can define JAVA_OPTS value in
Please help me out achieving my functionality.
thanks.
Upvotes: 2
Views: 8189
Reputation: 1108722
Wrap it in a class which extends a Map
.
public class SystemProperties extends HashMap<String, String> {
@Override
public String get(Object name) {
return System.getProperty(name != null ? name.toString() : null);
}
}
Declare it as follows in JSP.
<jsp:useBean id="systemProperties" class="com.example.SystemProperties" scope="application" />
Then you can just treat it as Map
in EL.
${systemProperties['MyProjectHome']}
or
${systemProperties.MyProjectHome}
Upvotes: 2
Reputation: 10498
Those are Java system properties. You can access it via the Java function
System.getProperty("MyProjectHome");
There might be a better way to do it in JSP but that will work.
Upvotes: 1
Reputation: 691725
what you pass to a JVM with -Dfoo=bar
is called a system property. You can get their value using System.getProperty()
. There is no standard tag or JSP EL syntax to get them, though, so you'll have to use scriptlet or implement a custom tag.
Upvotes: 2