top of page
Search

Servlet Container: How to Deploy and Manage Web Applications with Tomcat



Defines methods that all servlets must implement. A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the HyperText Transfer Protocol. To implement this interface, you can write a generic servlet that extends javax.servlet.GenericServlet or an HTTP servlet that extends javax.servlet.http.HttpServlet. This interface defines methods to initialize a servlet, to service requests, and to remove a servlet from the server. These are known as life-cycle methods and are called in the following sequence: The servlet is constructed, then initialized with the init method. Any calls from clients to the service method are handled. The servlet is taken out of service, then destroyed with the destroy method, then garbage collected and finalized. In addition to the life-cycle methods, this interface provides the getServletConfig method, which the servlet can use to get any startup information, and the getServletInfo method, which allows the servlet to return basic information about itself, such as author, version, and copyright.Author: VariousSee Also:GenericServlet, HttpServletMethod Summary voiddestroy() Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. ServletConfiggetServletConfig() Returns a ServletConfig object, which contains initialization and startup parameters for this servlet. java.lang.StringgetServletInfo() Returns information about the servlet, such as author, version, and copyright. voidinit(ServletConfig config) Called by the servlet container to indicate to a servlet that the servlet is being placed into service. voidservice(ServletRequest req, ServletResponse res) Called by the servlet container to allow the servlet to respond to a request. Method Detailinitvoid init(ServletConfig config) throws ServletExceptionCalled by the servlet container to indicate to a servlet that the servlet is being placed into service. The servlet container calls the init method exactly once after instantiating the servlet. The init method must complete successfully before the servlet can receive any requests. The servlet container cannot place the servlet into service if the init method Throws a ServletException Does not return within a time period defined by the Web server Parameters:config - a ServletConfig object containing the servlet's configuration and initialization parametersThrows:ServletException - if an exception has occurred that interferes with the servlet's normal operationSee Also:UnavailableException, getServletConfig()getServletConfigServletConfig getServletConfig()Returns a ServletConfig object, which contains initialization and startup parameters for this servlet. The ServletConfig object returned is the one passed to the init method. Implementations of this interface are responsible for storing the ServletConfig object so that this method can return it. The GenericServlet class, which implements this interface, already does this.Returns:the ServletConfig object that initializes this servletSee Also:init(javax.servlet.ServletConfig)servicevoid service(ServletRequest req, ServletResponse res) throws ServletException, java.io.IOExceptionCalled by the servlet container to allow the servlet to respond to a request. This method is only called after the servlet's init() method has completed successfully. The status code of the response always should be set for a servlet that throws or sends an error. Servlets typically run inside multithreaded servlet containers that can handle multiple requests concurrently. Developers must be aware to synchronize access to any shared resources such as files, network connections, and as well as the servlet's class and instance variables. More information on multithreaded programming in Java is available in the Java tutorial on multi-threaded programming.Parameters:req - the ServletRequest object that contains the client's requestres - the ServletResponse object that contains the servlet's responseThrows:ServletException - if an exception occurs that interferes with the servlet's normal operationjava.io.IOException - if an input or output exception occursgetServletInfojava.lang.String getServletInfo()Returns information about the servlet, such as author, version, and copyright. The string that this method returns should be plain text and not markup of any kind (such as HTML, XML, etc.).Returns:a String containing servlet informationdestroyvoid destroy()Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. After the servlet container calls this method, it will not call the service method again on this servlet. This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory. Overview Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes SUMMARY: NESTED FIELD CONSTR METHODDETAIL: FIELD CONSTR METHODSubmit a bug or feature Copyright 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms. Generated on 10-February-2011 12:41 var s_code=s.t();if(s_code)document.write(s_code)Scripting on this page tracks web page traffic,but does not change the content in any way.


A servlet is a Java programming language class that is used to extendthe capabilities of servers that host applications accessed by means of a request-responseprogramming model. Although servlets can respond to any type of request, they arecommonly used to extend the applications hosted by web servers. For such applications,Java Servlet technology defines HTTP-specific servlet classes.




servlet



The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. Allservlets must implement the Servlet interface, which defines life-cycle methods. When implementing a genericservice, you can use or extend the GenericServlet class provided with theJava Servlet API. The HttpServlet class provides methods, such as doGet anddoPost, for handling HTTP-specific services.


Servlets are the Java platform technology of choice for extending and enhancing Web servers. Servlets provide a component-based, platform-independent method for building Web-based applications, without the performance limitations of CGI programs. And unlike proprietary server extension mechanisms (such as the Netscape Server API or Apache modules), servlets are server- and platform-independent. This leaves you free to select a "best of breed" strategy for your servers, platforms, and tools.


Today servlets are a popular choice for building interactive Web applications. Third-party servlet containers are available for Apache Web Server, Microsoft IIS, and others. Servlet containers are usually a component of Web and application servers, such as BEA WebLogic Application Server, IBM WebSphere, Sun Java System Web Server, Sun Java System Application Server, and others.


You might want to check out the latest information on JavaServer Pages (JSP) technology. JSP technology is an extension of the servlet technology created to support authoring of HTML and XML pages. It makes it easier to combine fixed or static template data with dynamic content. Even if you're comfortable writing servlets, there are several compelling reasons to investigate JSP technology as a complement to your existing work.


Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. A servlet can almost be thought of as an applet that runs on the server side--without a face. Java servlets make many Web applications possible.


If you put the Camel JARs such as camel-core, camel-servlet, etc. in the boot classpath of your application server (eg usually in its lib directory), then mind that the servlet mapping list is now shared between multiple deployed Camel application in the app server.


Without more configuration it will reuse servlet thread pool to handle the processing but you can set executorRef to an executor service reference to let another pool handle the processing of the exchange. It will use camel context registry by default and potentially fallback on an executor policy or default executor service if no bean matches this name.


Next, the request URI "/book.html" will be handled by RedirectCXFServlet. Note that a uri pattern can be a regular expression. This servlet redirects the request further to a RequestDispatcher capable of handling a "/static/book.html".


Note that the redirects-list parameter has two space separated values, "/" and "index.html". The request attribute 'javax.servlet.include.request_uri' might need to be set for the underlying container like Jetty to successfully read "index.html".


A user who doesn't want to touch any Spring stuff could also publish the endpoint with CXF servlet transport. First you should extend the CXFNonSpringServlet and then override the method loadBus, e.g.:


Oracle Enterprise Manager (OEM) 13.5OEM is getting the following error "DFW-99998 [javax.servlet.ServletException][weblogic.servlet.AsyncInitServlet.service][consoleapp]"


You\u2019re ready to thrive, learn, share, and connect with others. And you\u2019re not alone.", "imageupload.max_uploaded_images_per_upload" : 10, "imageupload.max_uploaded_images_per_user" : 5000, "integratedprofile.connect_mode" : "", "tkb.toc_maximum_heading_level" : "", "tkb.toc_heading_list_style" : "disc", "sharedprofile.show_hovercard_score" : true, "config.search_before_post_scope" : "community", "tkb.toc_heading_indent" : "", "p13n.cta.recommendations_feed_dismissal_timestamp" : -1, "imageupload.max_file_size" : 4000, "layout.show_batch_checkboxes" : false, "integratedprofile.cta_connect_slim_dismissal_timestamp" : -1 }, "isAnonymous" : true, "policies" : "image-upload.process-and-remove-exif-metadata" : false , "registered" : false, "emailRef" : "", "id" : -1, "login" : "Community Alums" }, "Server" : "communityPrefix" : "/community/s/cgfwn76974", "nodeChangeTimeStamp" : 1675726968011, "tapestryPrefix" : "/community", "deviceMode" : "DESKTOP", "responsiveDeviceMode" : "DESKTOP", "membershipChangeTimeStamp" : "0", "version" : "22.12", "branch" : "22.12-release", "showTextKeys" : false , "Config" : "phase" : "prod", "integratedprofile.cta.reprompt.delay" : 30, "profileplus.tracking" : "profileplus.tracking.enable" : false, "profileplus.tracking.click.enable" : false, "profileplus.tracking.impression.enable" : false , "app.revision" : "2302010131-s48b13a6fef-b73", "navigation.manager.community.structure.limit" : "2500" , "Activity" : "Results" : [ ] , "NodeContainer" : "viewHref" : " -p/Developer", "description" : "Create custom applications for your service catalog, integrations, knowledge management, incident management, change and release management, notifications, and share knowledge.", "id" : "Developer", "shortTitle" : "Developer", "title" : "Developer", "nodeType" : "category" , "Page" : "skins" : [ "servicenow", "theme_hermes", "responsive_peak" ], "authUrls" : "loginUrl" : "/community/s/plugins/common/feature/oidcss/sso_login_redirect/providerid/default?referer=https%3A%2F%2Fwww.servicenow.com%2Fcommunity%2Fdeveloper-forum%2Fcan-t-find-property-quot-glide-servlet-uri-quot-under-sys%2Fm-p%2F2120223%2Fthread-id%2F777149", "loginUrlNotRegistered" : "/community/s/plugins/common/feature/oidcss/sso_login_redirect/providerid/default?redirectreason=notregistered&referer=https%3A%2F%2Fwww.servicenow.com%2Fcommunity%2Fdeveloper-forum%2Fcan-t-find-property-quot-glide-servlet-uri-quot-under-sys%2Fm-p%2F2120223%2Fthread-id%2F777149", "loginUrlNotRegisteredDestTpl" : "/community/s/plugins/common/feature/oidcss/sso_login_redirect/providerid/default?redirectreason=notregistered&referer=%7B%7BdestUrl%7D%7D" , "name" : "ForumTopicPage", "rtl" : false, "object" : "viewHref" : "/community/developer-forum/can-t-find-property-quot-glide-servlet-uri-quot-under-sys/td-p/2120223", "subject" : "can't find property "glide.servlet.uri" under sys_properties.LIST any Ideas where it chould be.", "id" : 2120223, "page" : "ForumTopicPage", "type" : "Thread" , "WebTracking" : "Activities" : , "path" : "Community:ServiceNow Community/Category:Discussions/Category:Developer/Board:Developer forum/Message:can't find property "glide.servlet.uri" under sys_properties.LIST any Ideas where it chould be." , "Feedback" : "targeted" : , "Seo" : "markerEscaping" : "pathElement" : "prefix" : "@", "match" : "^[0-9][0-9]$" , "enabled" : false , "TopLevelNode" : "viewHref" : " ", "description" : "", "id" : "cgfwn76974", "shortTitle" : "ServiceNow Community", "title" : "ServiceNow Community", "nodeType" : "Community" , "Community" : "viewHref" : " ", "integratedprofile.lang_code" : "en", "integratedprofile.country_code" : "US", "id" : "cgfwn76974", "shortTitle" : "ServiceNow Community", "title" : "ServiceNow Community" , "CoreNode" : "conversationStyle" : "forum", "viewHref" : " -forum/bd-p/developer-forum", "settings" : , "description" : "", "id" : "developer-forum", "shortTitle" : "Developer forum", "title" : "Developer forum", "nodeType" : "Board", "ancestors" : [ "viewHref" : " -p/Developer", "description" : "Create custom applications for your service catalog, integrations, knowledge management, incident management, change and release management, notifications, and share knowledge.", "id" : "Developer", "shortTitle" : "Developer", "title" : "Developer", "nodeType" : "category" , "viewHref" : " -p/User_forums", "description" : "", "id" : "User_forums", "shortTitle" : "Discussions", "title" : "Discussions", "nodeType" : "category" , "viewHref" : " ", "description" : "", "id" : "cgfwn76974", "shortTitle" : "ServiceNow Community", "title" : "ServiceNow Community", "nodeType" : "Community" ] };LITHIUM.Components.RENDER_URL = '/community/util/componentrenderpage/component-id/#component-id?render_behavior=raw';LITHIUM.Components.ORIGINAL_PAGE_NAME = 'forums/v5/ForumTopicPage';LITHIUM.Components.ORIGINAL_PAGE_ID = 'ForumTopicPage';LITHIUM.Components.ORIGINAL_PAGE_CONTEXT = 'Jc32nyeLAGJ5k2ccOf1Z_fwmUGrBqR_S0ZIAZVMGs-9R1YspU0lnUCM9k4IkjHS-nOcJxx9stj2E3lwOMB1NX0qiJTG-R3aP_K9LhqrtFkTkggQd7jRqwTE6nBUfrwlZQx9Hx4Ja21s_ZXutkXu4RJvEMmWFNKzdX81aGzpnLuQJJqUMIsmalRNJMEBJq9eCs8M40Le0DzQSDwVHIVKnLZfnYq109w7EqMwrYGzzqOO3e0QYzNNgaJJNtqT0SsSJZiWFZzVYRt7BKS7nVtrgJ1eRMlqp3R5U4nP0FYZKedZfhADXYGchyAkctX5oFeebnXDh36YxRr-giZjWLd2H64co3frACttq3YdrcO0GV3yjVZRUzbzLAsW2SIWvIts4Nd9ND08SXFSYcGxlJuVKGJHQOqCet2VnnQKD5AJg6d8.';LITHIUM.Css = "BASE_DEFERRED_IMAGE" : "lia-deferred-image", "BASE_BUTTON" : "lia-button", "BASE_SPOILER_CONTAINER" : "lia-spoiler-container", "BASE_TABS_INACTIVE" : "lia-tabs-inactive", "BASE_TABS_ACTIVE" : "lia-tabs-active", "BASE_AJAX_REMOVE_HIGHLIGHT" : "lia-ajax-remove-highlight", "BASE_FEEDBACK_SCROLL_TO" : "lia-feedback-scroll-to", "BASE_FORM_FIELD_VALIDATING" : "lia-form-field-validating", "BASE_FORM_ERROR_TEXT" : "lia-form-error-text", "BASE_FEEDBACK_INLINE_ALERT" : "lia-panel-feedback-inline-alert", "BASE_BUTTON_OVERLAY" : "lia-button-overlay", "BASE_TABS_STANDARD" : "lia-tabs-standard", "BASE_AJAX_INDETERMINATE_LOADER_BAR" : "lia-ajax-indeterminate-loader-bar", "BASE_AJAX_SUCCESS_HIGHLIGHT" : "lia-ajax-success-highlight", "BASE_CONTENT" : "lia-content", "BASE_JS_HIDDEN" : "lia-js-hidden", "BASE_AJAX_LOADER_CONTENT_OVERLAY" : "lia-ajax-loader-content-overlay", "BASE_FORM_FIELD_SUCCESS" : "lia-form-field-success", "BASE_FORM_WARNING_TEXT" : "lia-form-warning-text", "BASE_FORM_FIELDSET_CONTENT_WRAPPER" : "lia-form-fieldset-content-wrapper", "BASE_AJAX_LOADER_OVERLAY_TYPE" : "lia-ajax-overlay-loader", "BASE_FORM_FIELD_ERROR" : "lia-form-field-error", "BASE_SPOILER_CONTENT" : "lia-spoiler-content", "BASE_FORM_SUBMITTING" : "lia-form-submitting", "BASE_EFFECT_HIGHLIGHT_START" : "lia-effect-highlight-start", "BASE_FORM_FIELD_ERROR_NO_FOCUS" : "lia-form-field-error-no-focus", "BASE_EFFECT_HIGHLIGHT_END" : "lia-effect-highlight-end", "BASE_SPOILER_LINK" : "lia-spoiler-link", "FACEBOOK_LOGOUT" : "lia-component-users-action-logout", "BASE_DISABLED" : "lia-link-disabled", "FACEBOOK_SWITCH_USER" : "lia-component-admin-action-switch-user", "BASE_FORM_FIELD_WARNING" : "lia-form-field-warning", "BASE_AJAX_LOADER_FEEDBACK" : "lia-ajax-loader-feedback", "BASE_AJAX_LOADER_OVERLAY" : "lia-ajax-loader-overlay", "BASE_LAZY_LOAD" : "lia-lazy-load";LITHIUM.noConflict = true;LITHIUM.useCheckOnline = false;LITHIUM.RenderedScripts = [ "LazyLoadComponent.js", "Events.js", "EarlyEventCapture.js", "Placeholder.js", "MessageViewDisplay.js", "ElementQueries.js", "AjaxFeedback.js", "jquery.ui.dialog.js", "AutoComplete.js", "SpoilerToggle.js", "DropDownMenu.js", "HelpIcon.js", "jquery.effects.slide.js", "jquery.ui.position.js", "Namespace.js", "jquery.function-utils-1.0.js", "Throttle.js", "Auth.js", "jquery.position-toggle-1.0.js", "Globals.js", "jquery.ui.mouse.js", "jquery.tmpl-1.1.1.js", "jquery.scrollTo.js", "jquery.clone-position-1.0.js", "DeferredImages.js", "Loader.js", "ThreadedDetailMessageList.js", "InlineMessageEditor.js", "jquery.viewport-1.0.js", "Video.js", "jquery.autocomplete.js", "json2.js", "jquery.ui.core.js", "jquery.json-2.6.0.js", "jquery.ui.draggable.js", "Forms.js", "MessageBodyDisplay.js", "ResizeSensor.js", "addthis_widget.js", "Text.js", "jquery.delayToggle-1.0.js", "PartialRenderProxy.js", "jquery.effects.core.js", "Cache.js", "InformationBox.js", "DropDownMenuVisibilityHandler.js", "jquery.ajax-cache-response-1.0.js", "Components.js", "jquery.iframe-transport.js", "InlineMessageReplyContainer.js", "Tooltip.js", "InlineMessageReplyEditor.js", "NoConflict.js", "jquery.ui.widget.js", "ActiveCast3.js", "Link.js", "OoyalaPlayer.js", "AjaxSupport.js", "DataHandler.js", "jquery.iframe-shim-1.0.js", "jquery.blockui.js", "Attachments.js", "PolyfillsAll.js", "jquery.hoverIntent-r6.js", "prism.js", "jquery.appear-1.1.1.js", "Lithium.js", "jquery.placeholder-2.0.7.js", "jquery.ui.resizable.js", "jquery.lithium-selector-extensions.js", "ProductTagList.js", "jquery.css-data-1.0.js", "ElementMethods.js", "LiModernizr.js", "jquery.tools.tooltip-1.2.6.js", "SearchAutoCompleteToggle.js", "ForceLithiumJQuery.js", "jquery.fileupload.js", "SearchForm.js", "Sandbox.js", "jquery.js"];(function(){LITHIUM.AngularSupport=function(){function g(a,c)a=avar d,f,b=coreModule:"li.community",coreModuleDeps:[],noConflict:!0,bootstrapElementSelector:".lia-page .min-width .lia-content",bootstrapApp:!0,debugEnabled:!1,useCsp:!0,useNg2:!1,k=function()var a;return function(b)();LITHIUM.Angular=;return{preventGlobals:LITHIUM.Globals.preventGlobals,restoreGlobals:LITHIUM.Globals.restoreGlobals,init:function(){var a=[],c=document.querySelector(b.bootstrapElementSelector);a.push(b.coreModule);b.customerModules&&0(window.BOOMR_mq=window.BOOMR_mq[]).push(["addVar","rua.upush":"false","rua.cpush":"true","rua.upre":"false","rua.cpre":"false","rua.uprl":"false","rua.cprl":"false","rua.cprf":"false","rua.trans":"SJ-67970af6-54ae-45a3-a379-33ee3578be2b","rua.cook":"false","rua.ims":"false","rua.ufprl":"false","rua.cfprl":"false","rua.isuxp":"false","rua.texp":"norulematch"]); !function(a){var e=" -mpulse.net/boomerang/",t="addEventListener";if("True"=="True")a.BOOMR_config=a.BOOMR_config,a.BOOMR_config.PageParams=a.BOOMR_config.PageParams,a.BOOMR_config.PageParams.pci=!0,e=" -mpulse.net/boomerang/";if(window.BOOMR_API_key="RL5JW-PHDQ7-UYYZD-J2FGS-FE4LN",function(){function n(e)(new Date).getTime()if(!a.BOOMR!a.BOOMR.version&&!a.BOOMR.snippetExecuted){a.BOOMR=a.BOOMR,a.BOOMR.snippetExecuted=!0;var i,_,o,r=document.createElement("iframe");if(a[t])a[t]("load",n,!1);else if(a.attachEvent)a.attachEvent("onload",n);r.src="javascript:void(0)",r.title="",r.role="presentation",(r.frameElementr).style.cssText="width:0;height:0;border:0;display:none;",o=document.getElementsByTagName("script")[0],o.parentNode.insertBefore(r,o);try_=r.contentWindow.documentcatch(O)i=document.domain,r.src="javascript:var d=document.open();d.domain='"+i+"';void(0);",_=r.contentWindow.document_.open()._l=function()var a=this.createElement("script");if(i)this.domain=i;a.id="boomr-if-as",a.src=e+"RL5JW-PHDQ7-UYYZD-J2FGS-FE4LN",BOOMR_lstart=(new Date).getTime(),this.body.appendChild(a),_.write(" 2ff7e9595c


0 views0 comments

Recent Posts

See All
bottom of page