Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 968
Matt Ball Avatar asked Sep 27 '10 15:09

Matt Ball


People also ask

What is the display name tag web xml?

The optional display-name element specifies the Web application display name, a short name that can be displayed by GUI tools. Currently, this element is not used by WebLogic Server.

Why is web xml needed?

web. xml defines mappings between URL paths and the servlets that handle requests with those paths. The web server uses this configuration to identify the servlet to handle a given request and call the class method that corresponds to the request method.

Why deployment descriptor is used?

Deployment Descriptor is a simple XML document that is used to map URL to the servlet. It tells the container how to run servlet and JSP. In a web application, Deployment Descriptor file is saved with the name web.

What is session config in web xml?

The session-timeout element defines the default session timeout interval for all sessions created in this web application. The specified timeout must be expressed in a whole number of minutes. If the timeout is 0 or less, the container ensures the default behaviour of sessions is never to time out.


1 Answers

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)

like image 159
skaffman Avatar answered Oct 06 '22 23:10

skaffman