I'm a novice java programmer writing scripts to generate HTML pages. All the examples I've found use code like
I've been writing in perl for many years and the standard module, CGI.pm, allows me to use syntax like
This is much easier to read, much easier to code (you don't have to keep track of closing tags) and lets you virtually forget about encoding, escaping or quoting problems, to which the first example above would be particularly prone.
Is there a java class (I hope that's the correct terminology) that I can use to perform the same function - i.e. generate well-formed HTML tags with their attributes and arguments properly escaped and/or encoded? I've checked the FAQ and done several searches on this forum without success. Several search engines were similarly unforthcoming.
If there is no such standard class, would it be possible to abuse an XML generator class or can anyone point me towards a third-party solution?
I'm still struggling to find a java community equivalent to CPAN so please forgive me if I'm missing something obvious.
Yours,
fish
["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
Code:
strHTML += "<a href=\"" + strURL + "\">";
strHTML += strLinkText + "</a>\n";
I've been writing in perl for many years and the standard module, CGI.pm, allows me to use syntax like
Code:
$HTML .= a( {-href=>$strURL}, $strLinkText );
This is much easier to read, much easier to code (you don't have to keep track of closing tags) and lets you virtually forget about encoding, escaping or quoting problems, to which the first example above would be particularly prone.
Is there a java class (I hope that's the correct terminology) that I can use to perform the same function - i.e. generate well-formed HTML tags with their attributes and arguments properly escaped and/or encoded? I've checked the FAQ and done several searches on this forum without success. Several search engines were similarly unforthcoming.
If there is no such standard class, would it be possible to abuse an XML generator class or can anyone point me towards a third-party solution?
I'm still struggling to find a java community equivalent to CPAN so please forgive me if I'm missing something obvious.
Yours,
fish
["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur