Interface ServletContext Method Detail


Package javax.servlet

getAttribute

public java.lang.Object getAttribute(java.lang.String name)

Returns the servlet container attribute with the given name, or null if there is no attribute by that name.
An attribute allows a servlet container to give the servlet additional information not already provided by this interface.
The attribute is returned as a java.lang.Object or some subclass. Attribute names should follow the same convention as package names. The Java Servlet API specification reserves names matching java.*, javax.*, and sun.*.

Parameters


Name - a String specifying the name of the attribute

Returns

An Object containing the value of the attribute, or null if no attribute exists matching the given name


getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an Enumeration containing the attribute names available within this servlet context.
Use the getAttribute(java.lang.String) method with an attribute name to get the value of an attribute.

Returns


An Enumeration of attribute names


getContext

public ServletContext getContext(java.lang.String uripath)
Returns a ServletContext object that corresponds to a specified URL on the server.
This method allows servlets to gain access to the context for various parts of the server, and as needed obtain RequestDispatcher objects from the context.
The given path must be begin with "/", is interpreted relative to the server's document root and is matched against the context roots of other web applications hosted on this container.

In a security conscious environment, the servlet container may return null for a given URL.

Parameters

uripath - a String specifying the context path of another web application in the container.

Returns

The ServletContext object that corresponds to the named URL, or null if either none exists or the container wishes to restrict this access.



getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.
This method can make available configuration information useful to an entire "web application".

Parameters

name - a String containing the name of the parameter whose value is requested

Returns

A String containing at least the servlet container name and version number



getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Returns the names of the context's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters.

Returns

An Enumeration of String objects containing the names of the context's initialization parameters



getMajorVersion

public int getMajorVersion()
Returns the major version of the Java Servlet API that this servlet container supports. All implementations that comply with Version 2.4 must have this method return the integer 2.

Returns


2


getMimeType

public java.lang.String getMimeType(java.lang.String file)
Returns the MIME type of the specified file, or null if the MIME type is not known.
The MIME type is determined by the configuration of the servlet container, and may be specified in a web application deployment descriptor. Common MIME types are "text/html" and "image/gif".

Parameters


file - a String specifying the name of a file

Returns

A String specifying the file's MIME type


getMinorVersion

public int getMinorVersion()
Returns the minor version of the Servlet API that this servlet container supports.
All implementations that comply with Version 2.4 must have this method return the integer 4.


Returns


4


getNamedDispatcher

public RequestDispatcher getNamedDispatcher(java.lang.String name)
Returns a RequestDispatcher object that acts as a wrapper for the named servlet.
Servlets (and JSP pages also) may be given names via server administration or via a web application deployment descriptor.
A servlet instance can determine its name using ServletConfig.getServletName().
This method returns null if the ServletContext cannot return a RequestDispatcher for any reason.

Parameters

name - a String specifying the name of a servlet to wrap

Returns

A RequestDispatcher object that acts as a wrapper for the named servlet, or null if the ServletContext cannot return a RequestDispatcher





getRealPath

public java.lang.String getRealPath(java.lang.String path)
Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem would be served by a request for
"http://host/contextPath/index.html" where contextPath is the context path of this ServletContext.
The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators.
This method returns null if the servlet container cannot translate the virtual path to a real path for any reason

Parameters

path - a String specifying a virtual path

Returns

A String specifying the real path, or null if the translation cannot be performed

References By : tomcat.apache « Privious Post » « Next Post » share on :        :  

Love to hear your Views / Guidance / Recommendations on this Post…

Explore the Technology World

Computer Programming Terminologies Computer Programming Terminology is a general word for the group of specialized words or meanings relating to Computer Programming, and also the study of such t ...Read MoreNew features in JDK 12 with IntelliJ IDEADeveloped by JetBrains (formerly known as IntelliJ) ,IntelliJ IDEA is a Java integrated development environment (IDE) for developing computer software. It is av ...Read MoreGoogle Pay API Implementation Demo for AndroidIn this youtube Channel by Android Developers ,Learn how to implement the Google Pay API for Android with just a few lines of code and how it works with your ex ...Read MoreUnit Testing in .NET Core and Azure Devops pipelineUnit testing is a software testing method by which individual units of source code, usage procedures,sets of one or more computer program modules together with ...Read MoreThe mind behind Linux & GIT : Linus TorvaldsLinus Torvalds transformed technology twice — first with the Linux kernel, which helps power the Internet, and again with Git, the source code management ...Read MoreTensorflow and deep learningWith Tensorflow ,deep machine learning transitions from an area of research into mainstream software engineering. ...Read MoreJava program to return all possible permutations from collection of distinct numbersexample of Java program to return all possible permutations from collection of distinct numbers ...Read MoreReal Time Analytics with Spring Application Development FrameworkSpring is the most popular application development framework for enterprise Java.Millions of developers use Spring to build simple, truly portable, fast and fle ...Read MorePath Setting in Java When an application is launched from command prompt Windows OS searches for the executable program in the current working directory. The prompt throws an error ...Read MoreFacebook | whatsapp|Github | Twitter | LinkedIn | Youtube| reddit About | Cookies-Policy | Disclaimer | Site Map | Contact

Call / Visit for New Batch

Services

Why Join Us

  • ➯ Free Demo Classes
  • ➯ No Registration Fee
  • ➯ Interview Questions
  • ➯ Study Materials
  • ➯ Softwares
  • ➯ Aptitude & Reasoning
  • ➯ Placement Assitance

Address

  • MyJava Training Institute ,
  • Plot No.243 , shop No 14 ,
  • Secnd Floor , Zone-II ,
  • M.P.Nagar , Bhopal,
  • Madhya Pradesh ( 462011 )
  • ☎  08871209400 , 7987028543
  • 🌐 www.myjava.in
FacebookGoogle +TwitterYouTube

MyJava - java Training Institute