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
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"
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.