Put your text ad here
WestNIC provides reliable web hosting services
Web hosting directory, find affordable web hosting
Fastwebhost offers cheap web hosting & reseller hosting services
This FAQ is part of the Code Style Help and FAQ section. Join our premium content service for full access all FAQ answers.
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.
Examples of standard web servers include Apache httpd, Microsoft Internet Information Server (IIS), and Lighttpd, which primarily serve content using the HTTP protocol. Examples of Java Application servers include WebSphere Application Server from IBM, Oracle WebLogic Server and OC4J, JBoss, Apache Geronimo, Sun GlassFish Enterprise Server and SAP Netweaver.
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: The latest version of the Apache Tomcat servlet container is designed to run only using the Java Runtime Environment (JRE), not a full Java Software Development Kit.
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.
… full answer hidden
Premium members click below for full answer
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.
… full answer hidden
Premium members click below for full answer
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 initialised 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 initialisation.
… full answer hidden
Premium members click below for full answer
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.
A database connection pool can be created and managed directly by your servlet application, or obtained through the servlet container using the Java Naming and Directory Interface (JNDI). The Apache Commons DBCP project provides the database connection pooling service used by the Tomcat servlet container, but can also used independently from the container. Container managed connection pools must be accessed using the javax.sql.DataSource interface, as outlined in the Tomcat JNDI Datasource HOW-TO.
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.
A: To configure the Apache JServ servlet engine to serve custom error pages in the servlet zone, the ErrorDocument directive must be declared in specific Location sections in the jserv.conf configuration file. The file references point to directories in the document path for the main HTTP server, as above:
<Location /servlets> ErrorDocument 400 /error-docs/400.shtml ErrorDocument 403 /error-docs/403.shtml ErrorDocument 404 /error-docs/404.shtml ErrorDocument 500 /error-docs/500.shtml </Location> <Location /servlet> ErrorDocument 400 /error-docs/400.shtml ErrorDocument 403 /error-docs/403.shtml ErrorDocument 404 /error-docs/404.shtml ErrorDocument 500 /error-docs/500.shtml </Location>
Note, the servlet engine must be stopped and restarted to initiate these changes.
| Front-end FAQs | Back-end FAQs | Learn Java |
|---|---|---|
About us: site help, text ads and premium content FAQs.