WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.
Switch to your JSP, and inside the body tag, type
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:
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="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
And then inside the body, insert the following:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jspf</url-pattern>
<is-xml>true</is-xml>
</jsp-property-group>
</jsp-config>
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
ReplyDeleteThank 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