I’m fairly new to servlets so I hope this isn’t an obvious question. So I have a simple Java servlet I’ve created in NetBeans using a template. I have a context parameter I created in web.xml that lists allowed hosts (one of my request parameters is a URL which I’ll compare against this list):
<context-param>
<param-name>allowedHosts</param-name>
<param-value>
http://opendap.co-ops.nos.noaa.gov/thredds/wms/NOAA/CBOFS/MODELS/201206/nos.cbofs.fields.nowcast.20120612.t00z.nc?service=WMS&version=1.3.0&request=GetCapabilities
http://www.google.com
http://www.facebook.com
</param-value>
</context-param>
When I put only dummy URLs in like Google and Facebook, this works perfectly. However, when I add the first URL, the Tomcat server cannot even deploy. Looking at my logs, I see this at the top of a very long stacktrace:
SEVERE: Parse Fatal Error at line 19 column 146: The reference to entity "version" must end with the ';' delimiter.
org.xml.sax.SAXParseException: The reference to entity "version" must end with the ';' delimiter.
Line 19 column 146 indeed points to the “version” portion of that long URL I have in the list of context parameters. So obviously “version” is some kind of reserve word. If I remove the “version” parameter from this URL, “request” is also a problem.
I can get around this by doing just http://opendap.co-ops.nos.noaa.gov/thredds/wms/ as the URL (because ultimately I want a list of hosts not specific URLs anyway), but I was wondering what one would have to do to get around this otherwise… Is there a way to include URLs that have such “reserve words” in web.xml?
Thanks!
Just put “&” (without the quotes) instead of the ampersands in your URL.
Hope this helps – DF
Edit: Try this:
Edit2: PS These things are called “entities” in XML – do a Google for more info