I have a requirement where I need to populate the <p>
tag with value from a file(to allow configurable option) based on receiving query parameter.File will be selected based on a query param receiving. I have tried two approaches and both are working fine. But I want to know which method has better performance.
Method 1 - Read from properties file
<%@page import="java.io.IOException" %>
<%@page import="java.util.Properties" %>
<%
String userDir = request.getParameter("user");
InputStream in = null;
String propVal = null
try{
in = application.getResourceAsStream("/userDir/custom.properties");
Properties props = new Properties();
props.load(in);
propVal = props.getProperty("prop1");
} catch(IOException io) {
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
%>
<p><%=propVal%></p>
Method 2 - using <jsp:include
where test.txt has text value
<%
String filePath = "userDir/test.txt";
%>
<p><jsp:include page="<%=filePath%>" /></p>