Place your text ad here.
World class data recovery software and renowned raid recovery services
WestNIC provides reliable web hosting services
Free software downloads and drivers download resources
Ahosting.biz reseller hosting, managed dedicated server with 24/7 support
This FAQ is part of the Code Style Help and FAQ section. Use the help request form below if your question is not answered here, but make sure you are asking the right question first.
web.xml for?
web.xml for each server?
A: Web servers are primarily designed to deliver Web site content and not much besides. Application servers may include a Web server component, such as a Java servlet container, but manage it alongside other components, such as an Enterprise JavaBeans container, so that there is a shared execution context amongst them.
A: You are strongly recommended to join an existing servlet container project rather than write one yourself. A servlet container is an extremely complex system to create and most implementations have taken many years to develop to a robust, high performance standard. The Apache Tomcat container is an open source project that would be a good place to start.
A: Servlet classes are not normally initialised when the servlet container is first started, they are brought into service when the first request for the servlet is received. Much of the time this "just in time" approach will not cause a significant delay. If a servlet has overridden the init(ServletConfig) method with a with a lengthy initialisation stage, the first user must wait for the method to return before the servlet handles their request.
A: If the server or container object is not loaded in memory because it is shutting down or starting up, it will not be listening for requests and cannot accept connections. Any clients that attempt to connect to the server will normally fail after a client-specific timeout period.
A: When you first request a session through the HttpServletRequest object, the servlet container manages the creation and storage of a reference to the HttpSession object. If a subsequent request is received that corresponds with an existing session object, the HttpServletRequest getSession() method will return the session object created in the first request.
More details available to subscribers:
Is the session ID stored in the servlet or container?
web.xml for?
A: The web.xml file contains configuration information for a single Web application. It includes configuration entries for each of the filters and servlets in the application, and a set of URL mappings for each. There is also a set of configuration entries that apply to every filter, servlet and JSP in the Web application context.
Context, filter and servlet configurations may contain a set of name and value pairs that are loaded by the servlet container when it starts up. The URL mappings tell the container which resources should be used to process incoming requests, and the configuration parameters are used to pass variables to those resources.
A: A servlet URL mapping is the second part of a servlet configuration in a Web application's web.xml file. The first part declares the servlet and gives it a name, the URL mapping tells the servlet container on which URL the servlet should operate, as below.
More details available to subscribers:
What is a servlet URL mapping?
web.xml for each server?
A: The /WEB-INF/web.xml configuration scheme is common to all servlet containers that conform to the Java Servlet Specification version 2.2 and later. Some servlet containers have supplementary configuration files to apply their own special features. You need a web.xml file for each Web application you create. There is also a web.xml file for the servlet container as a whole.
A: To request a servlet is initialized when the container starts up, add the load-on-startup element to the web.xml file in your WEB-INF directory, as below. Any positive integer value will signal start up initialization.
More details available to subscribers:
How do I load a servlet at start-up?
A: The standard way to preserve database connections between servlet requests is to use a connection pool that governs access to a number of live connections. The pool uses your primary database driver to create the connections in advance and makes pooled connections available through its own URL identifier. When the application closes a pooled connection it just returns to the pool.
More details available to subscribers:
How can I create database connections for all servlets?
A: If your compiler is failing with missing javax package references, it is very likely your classpath does not include jsdk.jar, the Java Servlet Development Kit. You need to include a line like this in a backed up copy of your autoexec.bat file and reboot your computer:
SET CLASSPATH=%classpath%;c:\jsdk2.0\lib\jsdk.jar
You should use the path to your own installation of the JSDK archive. See the classpath section of Apache JServ on Windows 95 for further details.
| Front-end FAQs | Back-end FAQs | Learning Java |
|---|---|---|
See site help for questions about this site, our text ads and sponsored links services.