web.xml
is a standard JavaEE file and its structure is well-documented in the Servlet specification. In web.xml
, you declare the URL as it is known within your local JNDI namespace (java:comp/env
).
web.xml
should be located inside WEB-INF
, underneath your WAR project structure. If you are using an IDE (such as Eclipse) to create Web projects, this file should already be created for you (unless you use Servlet Specification 2.5 and up - Servlet Specification 2.5 is included with JavaEE 5.0 - where deployment descriptors are optional).
ibm-web-bnd.xml
is a WebSphere-specific file. It contains the binding of declared artifacts (such as a URL definition) into a real artifacts. You should refer to IBM's documentation in order to figure out the format of that file.
The ibm-web-bnd.xml
file should be located in the same directory as web.xml
.
The id
attribute of resource-ref
can be set to any value you like, as long as it is cross-referenced by a matching id
attribute inside ibm-web-bnd.xml
. That's how WebSphere can correlate definitions in ibm-web-bnd.xml
to definitions in web.xml
. The random string you see in the tutorial are created by RAD or WSAD; you can place any identifier there.
EDIT (added instructions)
In a nutshell, the process is this:
In web.xml
, you define the local JNDI name. That would be the name by which your Java code is referring to the URL. For example, myWebsiteUrl
. Your code will have to perform a JNDI lookup on java:comp/env/myWebsiteUrl
. The definition is along these lines:
<resource-env-ref>
<resource-env-ref-name>myWebsiteUrl</resource-env-ref-name>
<resource-env-ref-type>java.net.URL</resource-env-ref-type>
</resource-env-ref>
In WebSphere itself, add a URL definition. The key there is the JNDI name in WebSphere's JNDI tree by which the URL will be known. You can set any value there, although it is recommended (by convention) that you prefix it with url/
. For example: url/test
.
In ibm-web-bnd.xml
, you need to bind myWebsiteUrl
(looked-up by your application) to url/test
(which is the JNDI name by which WebSphere knows the URL). The definition will be along the lines of:
<resource-env-ref name="myWebsiteUrl" binding-name="url/test"/>
Step 3 is not required. If ibm-web-bnd.xml
doesn't exist at deployment time, then the GUI-based deployment flow (used when you deploy applications through the WAS administration console) will prompt you for the binding values. (If you are deploying using scripting, you can still omit the ibm-web-bnd.xml
file as long as you specify the bindings in a different way, but that's beyond the scope of this answer. Read the IBM documentation about strategy files and AdminApp.installApplication
)
Note: as long as you use JavaEE 5.0 and up, you don't need the id
attribute in the definitions. The article you're reading, by the way, is extremely outdated.