What is a servlet's "display-name" for?
Asked Answered
I

5

24

The <display-name> element appears to be a valid sub-element of the <servlet> element as per the Servlet 2.5 deployment descriptor XSD. That is, according to Eclipse's XML validator, this:

<servlet>
    <servlet-name>FooServlet</servlet-name>
    <display-name>FooServlet</display-name>
    <servlet-class>com.bar.servlet.FooServlet</servlet-class>
</servlet>

is a valid servlet-mapping, while this:

<servlet>
    <servlet-name>FooServlet</servlet-name>
    <random-tag-name>OMGWTFBBQ</random-tag-name>
    <servlet-class>com.bar.servlet.FooServlet</servlet-class>
</servlet>

is not (which seems reasonable enough).

What's the display-name actually used for? I haven't been able to dig up anything informative on it.

Idonna answered 27/9, 2010 at 15:22 Comment(0)
L
20

The <servlet-name> is the canonical, internal name of the servlet, and is used as the key linking things like url-patterns to servlets. <display-name> is for use by admin tools and the like.

This perhaps makes more sense when you consider that the XML Schema permits multiple <display-name> elements, for various languages, e.g.

<servlet>
    <servlet-name>MyServlet</servlet-name>
    <displayable-name xml:lang="en">My Servlet</displayable-name>
    <displayable-name xml:lang="fr">Ma Servlet</displayable-name>
</servlet>

(pardon my Frenglais)

Libbi answered 27/9, 2010 at 15:36 Comment(2)
<display-name xml:lang="de">Mein Servlet</display-name>Tiatiana
+1 for Frenglais and canonical. I generally understood what the <servlet-name> was for (really wasn't confused about that part), but "canonical" is the word to describe it.Idonna
V
7

The servlet-name is used to refer to the servlet in other tags (like servlet-mapping). This could be thought of as the "internal name" of the servlet. The display-name is the "external name" of the servlet - it's what should show up on a management consoles of servlet containers. Usually, web apps are managed as a unit - they are deployed/undeployed/restarted/etc. as a whole, not managing individual servlets - so there's not a place where you would usually see this display name used.

Viaduct answered 27/9, 2010 at 15:32 Comment(0)
S
5

I believe it's used primarily by J2EE web-management consoles, when displaying statistics, etc.

Stillness answered 27/9, 2010 at 15:30 Comment(0)
M
1

The <display-name> element is a child element of <servlet>. These are elements used within web.xml deployment descriptor files. The <display-name> is optional and allows for a short name to be associated with the servlet which can be potentially read by GUI tools (such as a web browser) to literally display the name of the servlet to the client if that is required. However, in practice, it is almost never used so can be safely disregarded.

Micmac answered 14/2, 2018 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.