<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.util.Properties" %>
<%
FileInputStream file = new FileInputStream(request.getRealPath("test.file"));
Properties prop = new Properties();
prop.load(file);
String db_url = prop.getProperty("db.url");
%>
<html>
<head></head>
<body>
<%out.print("Test N 11");%>
<br>
<%out.print(request.getRealPath("/"));%>
<br>
<%out.print("From parfile: " + db_url);%>
</body>
</html>
Листинг test.file
db.driver=oracle.jdbc.driver.OracleDriver
db.url=jdbc:oracle:thin:@dbserver:1521:ORACLESID
db.user=MY_ORA_SCHEMA
db.password=pass
В браузере будет следующее:
Test N 11
/opt/apache-tomcat/webapps/my_app/
From parfile: jdbc:oracle:thin:@jdbc:oracle:thin:@dbserver:1521:ORACLESID
Комментариев нет:
Отправить комментарий