The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by mantrika]

I am trying to parse a RSS XML document using JSTL <x:parse ..>. But I keep
getting the following Jasper exception:
org.apache.jasper.JasperException: External entity not found:
"http://my.netscape.com/publish/formats/rss-0.91.dtd.

I can get to the above dtd site using my browser(using proxies??). I think the
host lookup is failing because I am behind a firewall. I donot have control
over the generation of the RSS files I am parsing. Hence I cannot change the
<!DOCTYPE to a local URI.>

What are the ways to bypass the external DTDs and use the local DTDs in JSTL?.
I read that we can use catalogs or write our own EntityResolver classes to
bypass. What are your suggestions? Is there a way to specifiy to JSTL tags to
use a mapping from External to Local DTS?

Thanks a lot.
import-bot (20211) [Avatar] Offline
#2
Re: Validating using External DTDs
[Originally posted by bayern]

> I am trying to parse a RSS XML document using JSTL <x:parse ..>. But I keep
> getting the following Jasper exception:
> org.apache.jasper.JasperException: External entity not found:
> "http://my.netscape.com/publish/formats/rss-0.91.dtd.
>
> I can get to the above dtd site using my browser(using proxies??). I think the
> host lookup is failing because I am behind a firewall. I donot have control
> over the generation of the RSS files I am parsing. Hence I cannot change the
> <!DOCTYPE to a local URI.>
>
> What are the ways to bypass the external DTDs and use the local DTDs in JSTL?.
> I read that we can use catalogs or write our own EntityResolver classes to
> bypass. What are your suggestions? Is there a way to specifiy to JSTL tags to
> use a mapping from External to Local DTS?

The <x:parse> tag shouldn't be using the DTD at all. Can I see a sample of
code from your JSP page?

Shawn
import-bot (20211) [Avatar] Offline
#3
Re: Validating using External DTDs
[Originally posted by mantrika]

> > I am trying to parse a RSS XML document using JSTL <x:parse ..>. But I keep
> > getting the following Jasper exception:
> > org.apache.jasper.JasperException: External entity not found:
> > "http://my.netscape.com/publish/formats/rss-0.91.dtd.
> >
> > I can get to the above dtd site using my browser(using proxies??). I think
the
> > host lookup is failing because I am behind a firewall. I donot have control
> > over the generation of the RSS files I am parsing. Hence I cannot change
the
> > <!DOCTYPE to a local URI.>
> >
> > What are the ways to bypass the external DTDs and use the local DTDs in
JSTL?.
> > I read that we can use catalogs or write our own EntityResolver classes to
> > bypass. What are your suggestions? Is there a way to specifiy to JSTL tags
to
> > use a mapping from External to Local DTS?
>
> The <x:parse> tag shouldn't be using the DTD at all. Can I see a sample of
> code from your JSP page?
>
> Shawn

This is just an example I was trying out. The RSS is copied from
http://www.cnn.com/cnn.rss site.

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>

<c:set var="xml">
<?xml version="1.0"?>

<!DOCTYPE rss PUBLIC >
"-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
<channel>
<title>News from CNN.com</title>
<link>http://cnn.com/index.html</link>
<description>The world's news leader</description>
<language>en-us</language>
<image>
<title>CNN.com</title>
<url>http://cnn.com/images/1999/07/cnn.com.logo.gif</url>
<link>http://CNN.com/index.html</link>
<width>144</width>
<height>34</height>
<description>The world's news leader</description>
</image>
<item>
<title>CNN.com</title>
<link>http://cnn.com</link>
</item>
</channel>
</rss>
</c:set>

<x:parse xml="${xml}" var="rss"/>

<table width='99%' border='0' cellpadding='1' cellspacing='3'>
<x:forEach select="$rss//item">
<tr>
<td align=left>
<x:out select='title'/>
</td>
</tr>
</x:forEach>
</table>
import-bot (20211) [Avatar] Offline
#4
Re: Validating using External DTDs
[Originally posted by mantrika]

To make 100% sure that it is going out to get the DTD definitions as outlined
in my previous posts, I did the following two tests. Both of which worked
fine.

1. Change the URI to point to a local dtd file

<!DOCTYPE rss PUBLIC>
"-//Netscape Communications//DTD RSS 0.91//EN"
"rss-0.91.dtd">

2. Specifying the proxy host and the port when starting up the JVM. In this
case it could get to the external dtd.

BTW, your book has been helping me immensely in developing apps a lot faster.

Thanks
import-bot (20211) [Avatar] Offline
#5
Re: Validating using External DTDs
[Originally posted by bayern]

> BTW, your book has been helping me immensely in developing apps a lot faster.

That's great to hear! Best,

Shawn