Page Fragments, Entities and Characters

Switch to your JSP, and inside the body tag, type

One Piña Colada, Please!
If you run, you should see the expected text in the browser.

Now try the same thing, but edit the text inside a page fragment. If you deploy, you'll see this in the browser:

One Piña Colada, Please!

Uh oh! What happened?

Turns out the app server doesn't realize that the page fragment file, the jspf file, should be interpreted as an XML-formatted JSP, just like the main document. As a result, the source fragment file (which is just a static JSP include behind the scenes) gets, well, mistreated. You can see a very similar thing with entities. If you go and insert JSPX entities in your fragment, these will not be correctly expanded and instead of spaces you'll see things like " ".

Here's how you can fix this. You basically need to tell the deployment container that it needs to treat .jspf files as XML formatted JSPs. Unfortunately, you can only do that using JSP 2.0. That means this won't work on deployment containers that don't support JSP 2.0. The bundled one, Sun Application Server 8.1, does (as does 8.0 which we shipped with Creator 1.0, so this solution works for Creator 1.0 as well.)

Switch to the Files view (it's in the same window container as the project navigator), drill into your project, then open web/WEB-INF/web.xml. Switch to the XML view. Replace the root <webapp> element with the following:

<web-app version="2.4" xmlns=""
And then inside the body, insert the following:

This is how this should look:

Now when you deploy, the page fragment text should be treated the way it's supposed to - and your Piña Colada will be on the way.

So why don't we just add this configuration info to the default web.xml we ship with Creator? Well, then you would no longer be able to use Creator with any older app servers. We're trying to hard to be compatible. However, we might be able to do something better here. I'll talk to Mr. Deployment to see what we can do.


Hi, This solution seems to be very easy... But in fact, I have an issue with it: now my domain.xml file seems to be crashed, and as a result, I can't launch the sun java application server, even if I try to restore the web.xml file. Here are the last lines of the server.log file: > > =============================================== > java.util.logging.ErrorManager: 0: Error In getLogService com.sun.enterprise.config.ConfigException: Error refreshing ConfigContext:C:\\Creator\\SunAppServer8\\domains\\creator\\config\\domain.xml cause: Failed to create the XML-DOM Document. Check your XML to make sure it is correct. Attribute "context-root" is required and must be specified for element type "web-module". at com.sun.enterprise.config.ConfigContextImpl.refresh( at com.sun.enterprise.config.ConfigContextImpl.refresh( at com.sun.enterprise.config.ConfigContextImpl.getRootConfigBean( at com.sun.enterprise.config.ConfigBeansFactory.getConfigBeanByXPath( at com.sun.enterprise.config.serverbeans.ServerBeansFactory.getServerBean( at com.sun.enterprise.config.serverbeans.ServerBeansFactory.getConfigModel( at com.sun.enterprise.config.serverbeans.ServerBeansFactory.getConfigBean( at com.sun.enterprise.server.logging.ServerLogManager.getLogService( at com.sun.enterprise.server.logging.FileandSyslogHandler.publish( at java.util.logging.Logger.log( at java.util.logging.Logger.doLog( at java.util.logging.Logger.log( at com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingByteArrayOutputStream.flush( at at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes( at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer( at sun.nio.cs.StreamEncoder.flushBuffer( at at at at at com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingPrintStream.println( at java.lang.Throwable.printStackTraceAsCause( at java.lang.Throwable.printStackTraceAsCause( at java.lang.Throwable.printStackTrace( at java.lang.Throwable.printStackTrace( at java.util.logging.ErrorManager.error( at com.sun.enterprise.server.logging.ServerLogManager.getLogService( at com.sun.enterprise.server.logging.ServerLogManager.initializeLogger( at com.sun.enterprise.server.logging.BaseLogManager.doInitializeLogger( at com.sun.enterprise.server.logging.BaseLogManager.addLogger( at java.util.logging.Logger.getLogger( at sun.rmi.runtime.Log$LoggerLogFactory.createLog( at sun.rmi.runtime.Log.getLog( at sun.rmi.server.UnicastRef.<clinit>( at java.rmi.server.RemoteServer.<clinit>( at at at com.sun.enterprise.admin.server.core.AdminService.init( at com.sun.enterprise.admin.server.core.AdminServiceLifeCycle.onInitialization( at com.sun.enterprise.server.ApplicationServer.onInitialization( at at com.sun.enterprise.server.PEMain.main( at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at Caused by: org.netbeans.modules.schema2beans.Schema2BeansNestedException: Failed to create the XML-DOM Document. Check your XML to make sure it is correct. Attribute "context-root" is required and must be specified for element type "web-module". at org.netbeans.modules.schema2beans.GraphManager.createXmlDocument( at org.netbeans.modules.schema2beans.BaseBean.createGraph( at com.sun.enterprise.config.ConfigContextImpl.refresh( ... 47 more Caused by: org.xml.sax.SAXParseException: Attribute "context-root" is required and must be specified for element type "web-module". at org.apache.xerces.parsers.DOMParser.parse( at org.apache.xerces.jaxp.DocumentBuilderImpl.parse( at org.netbeans.modules.schema2beans.GraphManager.createXmlDocument( ... 49 more > ============================================== > > I'm working on winXP Pro. Why don't you seem to have the same matter?

Posted by Original Prankster on September 20, 2005 at 10:20 PM PDT #

hi Thank you for the entry. but it does not works. I have a jsf portlet build by creator 2 , when i add your code snippet to web.xml it say : Deploying application in domain failed; Error loading deployment descriptors for Advertiser Line 10 Column 111 -- Attribute "version" must be declared for element type "web-app". can you please clearify , whether this works with jsf portlet or not , what is my mistake that i return error

Posted by legolas woodland on January 13, 2006 at 07:15 PM PST #

Post a Comment:
Comments are closed for this entry.

Tor Norbye


« February 2016