You can configure a mapping between an extension and a mime type in the DD. This will probably be the easiest tag to remember, because it just makes sense—you map between an extension and a mime-type, and guess what? In a rare moment of simplicity and clarity, they named the tag sub-elements “extension” and “mime-type”. That means you have to remember only one thing—that the tag elements are named for exactly what they are!
Unless you start thinking of it as “file-type” and “content-type”. But no, you won’t do that. You’ll memorize it just like this.
Declaring a <mime-mapping>
Don’t include the “.” in the extension!
It’s just the characters that make up the extension, not the “.” that separates the file name from the extension.
It’s not <file-type> and <content-type>!
Burn it in—<extension> and <mime-type>.
<extension> and <mime-type>
<extension> and <mime-type>
<extension> and <mime-type>
<extension> and <mime-type>
Sharpen your pencil
Fill in this table with explicit notes on where in the web app the given resource must be placed. We did the first one for you. Turn the page for the answers.
Resource type | Deployment location |
---|---|
Deployment Descriptor (web.xml) | Directly inside WEB-INF (which is directly inside the root of the web app). |
Tag Files (.tag or .tagx) | |
HTML and JSPs (That you want to be directly accessible.) | |
HTML and JSPs (That you want to “hide” from direct client access.) | |
TLDs (.tld) | |
Servlet classes | |
Tag Handler classes | |
JAR files |
Sharpen your pencil
Memorizing DD tags
If you’re NOT planning on taking the exam, don’t worry about getting all of these right (although the bottom two elements are important to almost everyone).
If you ARE going to take the exam, you should spend some time memorizing these.
< _________________ > < _________________ >ejb/Customer< _________________ > <ejb-ref-type>Entity</ejb-ref-type> < _________________ >com.wickedlysmart.CustomerHome< _________________ > <local>com.wickedlysmart.Customer</local> < _________________ >
<ejb-ref> < _________________ >ejb/LocalCustomer< _________________ > <ejb-ref-type>Entity</ejb-ref-type> < _________________ >com.wickedlysmart.CustomerHome< _________________ > < _________________ >com.wickedlysmart.Customer< _________________ > </ejb-ref>
<env-entry> < _________________ >rates/discountRate< _________________ > < _________________ >java.lang.Integer< _________________ > <env-entry-value>10</env-entry-value> </env-entry>
<error-page> < _________________ >java.io.IOException< _________________ > < _________________ >/myerror.jsp< _________________ > </error-page>
< _________________ > <welcome-file>index.html</welcome-file> < _________________ >
Sharpen your pencil
Where things go
Fill in this table with explicit notes on where in the web app the resource must be placed. We did the first one for you.
Resource type | Deployment location |
---|---|
Deployment Descriptor (web.xml) | Directly inside WEB-INF (which is directly inside the root of the web app). |
Tag Files (.tag or .tagx) | If NOT deployed inside a JAR, Tag Files must be inside WEB-INF/tags, or a subdirectory of WEB-INF/tags. If deployed in a JAR, Tag Files must be in META-INF/tags, or a subdirectory of META-INF/tags. Note: Tag Files deployed in a JAR must have a TLD in the JAR. |
HTML and JSPs (That you want to be directly accessible.) | Client-accessible HTML and JSPs can be anywhere under the root of the web app or any of its subdirectories, EXCEPT they cannot be under WEB-INF (including subdirectories). In a WAR file, they can’t be under META-INF (including subdirectories). |
HTML and JSPs (That you want to “hide” from direct client access.) | Pages under WEB-INF (or META-INF in a WAR file) cannot be directly accessed by clients. |
TLDs (.tld) | If NOT inside a JAR, TLD files must be somewhere under WEB-INF or a subdirectory of WEB-INF. If deployed in a JAR, TLD files must be somewhere under META-INF, or a subdirectory of META-INF. |
Servlet classes | Servlet classes must be in a directory structure matching the package structure, placed directory under WEB-INF/classes (for example, class com. example.Ring would be inside WEB-INF/classes/com/example), or in the appropriate package directories within a JAR inside WEB-INF/lib). |
Tag Handler classes | Actually ALL classes used by the web-app (unless they’re part of the class libraries on the classpath) must follow the same rules as servlet classes—inside WEB-INF/classes, in a directory structure matching the package (or in the appropriate package directories within a JAR inside WEB-INF/lib). |
JAR files | JAR files must be inside the WEB-INF/lib directory. |
Sharpen your pencil
Memorizing DD tags
ANSWERS
If you are going to take the exam, you should spend some time memorizing ALL of these (plus any of the others from from this chapter and the security-related tags you’ll see in the next chapter).
< ejb-local-ref > < ejb-ref-name >ejb/Customer< /ejb-ref-name > <ejb-ref-type>Entity</ejb-ref-type> < local-home >com.wickedlysmart.CustomerHome< /local-home > <local>com.wickedlysmart.Customer</local> < /ejb-local-ref >
<ejb-ref> < ejb-ref-name >ejb/LocalCustomer< /ejb-ref-name > <ejb-ref-type>Entity</ejb-ref-type> < home >com.wickedlysmart.CustomerHome< /home > < remote >com.wickedlysmart.Customer< /remote > </ejb-ref>
<env-entry> < env-entry-name >rates/discountRate< /env-entry-name > < env-entry-type >java.lang.Integer< /env-entry-type > <env-entry-value>10</env-entry-value> </env-entry>
<error-page> < exception-type >java.io.IOException< /exception-type > < location >/myerror.jsp< /location > </error-page>
< welcome-file-list > <welcome-file>index.html</welcome-file> < /welcome-file-list >