Recommended web.xml for JSF

The file web.xml inside the WEB-INF folder is the Web Application Deployment Descriptor for your application. This is an XML file describing the servlets and other components that make up your application. The file below is what I use at work. It contains better settings than the default one, plus all descriptions of parameters.

Server is recommended. Ive tried one day client, but HTML pages were 10Mb big!

<context-param> <description>Only applicable if state saving method is "server" (= default) and iforg.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (=default) If true (default) the serialized state will be compressed before it is written to the session. If false the state will not be compressed. </description> <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION </param-name> <param-value>true</param-value> </context-param>

You should always balanced cpu/memory usage. (Compressing state cost CPU but spare memory…obvious)

<context-param> <description>Only applicable if state saving method is "server" (= default). If true (default) the state will be serialized to a byte stream before it is written to the session. If false the state will not be serialized to a byte stream. </description> <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION </param-name> <param-value>false</param-value> </context-param>

Compressing data save memory bytes on server at the cost of more computational power.

Number of back button. Default is 20. far too much. reducing this value decrease memory size.

<context-param> <description>This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output. If javascript is allowed, command_link anchors will have javascript code that submits the corresponding form. If javascript is not allowed, the state saving info and nested parameters will beadded as url parameters. Default: "true" </description> <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name> <param-value>false</param-value> </context-param>

Nothing special here. Most of the time, webpage are full of javascript.

<context-param> <description>The buffer size to set on the response when the ResponseWriter is generated. By default the value is -1, which will not assign a buffer size on the response. </description> <param-name>facelets.BUFFER_SIZE</param-name> <param-value>8192</param-value> </context-param>

<context-param> <description>If true, rendered HTML code will be formatted, so that it is "human readable". i.e. additional line separators and whitespace will be written, that do not influence the HTML code. Default: "true" </description> <param-name>org.apache.myfaces.PRETTY_HTML</param-name> <param-value>false</param-value> </context-param>

<context-param> <description>If true, a javascript function will be rendered that is able to restore the former vertical scroll on every request. Convenient feature if you have pages with long lists and you do not want the browser page to always jump to the top if you trigger a link or button action that stays on the samepage. Default: "false" </description> <param-name>org.apache.myfaces.AUTO_SCROLL</param-name> <param-value>true</param-value> </context-param>

About The Author

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT

Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.