Could someone explain the main differences (or provide a link to) between glassfish-web.xml
, sun-web.xml
and web.xml
?
Can I use just glassfish-web.xml
in my webapp and skip the others?
The glassfish-web.xml file configures a web application (WAR file). The element hierarchy is as follows: glassfish-web-app . context-root .
The sun-web.xml file configures a web application (WAR file). The element hierarchy is as follows: sun-web-app . context-root . security-role-mapping . . role-name . .
The GlassFish Server web application runtime DD, if used, is named glassfish-web. xml and is located in the WEB-INF directory.
xml is used for server and context. xml is for application that runs on that server. There may be several context. xml files (per application) on a server but only one server. xml.
You may or may not need a web.xml file. It depends on the Java EE features you use. By default, don't use any of these files and simply use Java EE annotations like @WebServlet. As you build out your app and perhaps begin using some features that require the web.xml file (like to define the JavaServer Faces FacesServlet), then use a web.xml file. As for the glassfish-web.xml, you only use one if you have GlassFish-specific features to configure for your application.
The Java EE tutorial is also a good way to learn Java EE, and is bundled with the Java EE 7 SDK along with GlassFish 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With