Java EE - finding common web.xml specification

I am new to Java EE. I found out that web.xml is a standard file (deployment descriptor) used by many servlet containers / app servers like tomcat, glassfish, etc. In many tutorials I can find various XML tags that I have to put custom values โ€‹โ€‹somewhere to achieve the given functionality (in the context of the tutorial). But this is quite chaotic - I don't know if I can reuse the tag inside spring / tomcat that was originally used in glassfish / jsf (this is just an example of the problem). Is there one big Java EE specification for web.xml so I can know what tags can be placed there, regardless of the web servers and frameworks used?

I read, for example, tomcat has some specific options provided for the web.xml file, so I think each server will behave differently (just like how web browsers can interpret HTML / CSS differently). - but is there a lot of documentation somewhere (regardless of structure)?

+3


source to share


3 answers


Usually in the java world, the general specification is called JSR. For example, the Servlet specification contains a definition for web.xml (and how to interpret it). There are several versions of the servlet, and they are defined by different JSR-s. For example, the Servlet 2.4 spec can be found here: http://jcp.org/en/jsr/detail?id=154 (this is called JSR-154)

I think the spec does not allow different vendors to use different web.xml's. Instead, they advise you to use a different file with web.xml. Since Tomcat was used as a reference implementation of Servlets (but nothing more), I think tomcat is very strict with JSR.



Currently the latest Servlet specification 3.0 (3.1 coming soon)

+4


source


The official spec, of course, refers to the various JSRs as mentioned above.

But a handy trick is to look at the "schemaLocation" attribute at the top of the xml file. put this in a web browser and you get an XSD document that contains all the tags and comments.

You will also find information on the second part of your question in these specs. Annotations provide configurations that can be overridden by values โ€‹โ€‹in deployment descriptors (web.xml), and each application server brand can also include additional configuration information in its own deployment descriptors. i.e. WEB-INF / JBoss-web.xml



These vendor-specific deployment descriptors can have tags with the same names as web.xml and override web.xml values.

Web.xml (and other standard deployment descriptors) is standardized as standard. The specific vendor deployment descriptors depend on each application server vendor.

+2


source


I think you should always look at the documentation related to the application server you are using.

eg. if you are using WebSphere see this

for WebLogic see this

Interestingly, in Servlet 3.0, you can create an application that cannot use the deployment descriptor at all using annotations. This does not mean that WEB.xml will no longer be used. here is a good article about servlet 3.0.

+1


source







All Articles