there are two things that u are trying to find as per my understanding
1. PRIVIDER_URL:
2. how-to lookup:
now both of these should be configurable and should not be hardcoded in the application so that tomorrow if u change the url/lookup location of ur file u do not have to re-compile ur code.
both the things can be done using environment entries. These entries are to be provided in the web.xml for the web application.
eg. add the following in your web.xml after taglib entries(if u have any)
<env-entry>
<env-entry-name>Provider_url</env-entry-name>
<env-entry-value>
t3://localhost:7001</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>file_location</env-entry-name>
<env-entry-value>C:\xfz\myfile.xls</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
And now read these values as
Context context=new InitialContext();
Strinf fl = (String) context.lookup("java:comp/env/file_location");
String url= (String) context.lookup("java:comp/env/Provider_url");
Note: PROVIDER_URL -> Its the location where your JNDI service is running. In case of weblogic the service runs on the same port where the server is started. In case of other app servers find out where the t3 service is running and the value for provider url should be accordingly set.
Let me know ur concerns if any