[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Embedding HTML in JSP

Subject: Re: Embedding HTML in JSP
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 5 Apr 2001 18:12:37 +0100
jsp escape html
Hi Amit,

Welcome to the list.

>       Trying to output :
>      <input type="hidden" name="ProductID" 
> value="<%=request.getParameter(\"productid\")%>">
>      the \ act as the escape characters.

Unfortunately (but perhaps unsurprisingly), XSLT processors don't
understand JSP. As far as an XSLT processor is concerned - in fact, as
far as an XML parser or an HTML browser's concerned - the above syntax
is illegal, because they don't recognise \ as an escape character and
therefore think that you close the attribute with the first ".

In fact, I'm very surprised that you managed to get a processor to
output:

 <input type="hidden" name="ProductID"
        value="<%=request.getParameter(\&quot;productid\&quot;)%>">

as again, this is non-well-formed XML/HTML - less than signs should be
escaped with entities in XML/HTML to give:

 <input type="hidden" name="ProductID"
        value="&lt;%=request.getParameter(\&quot;productid\&quot;)%>">

I think you're probably viewing the output in something like IE that
automatically unescapes the less-than sign for the view - have a look
at the raw source in a basic text editor to see what's really there.

Mainly, processors output attribute values using double quotes. Hence,
they have to escape double quotes in the attribute values using &quot;
to keep it legal. So if you can, I suggest that you change the JSP to
use single quotes rather than double quotes.  Just give:

  <input type="hidden" name="ProductID"
         value="&lt;%=request.getParameter(\'productid\')%>" />

in the stylesheet - there's no need to use xsl:element.

Here, the processor doesn't need to escape the single quotes (although
it legally can, just as it can legally escape any character in the
attribute value). This will not get around the fact that you get an
escaped less-than sign in the output.

If you absolutely want the string:

  <input type="hidden" name="ProductID"
         value="<%=request.getParameter(\"productid\")%>">

Then the only way to get it is to disable output escaping and
construct the entire element as text (you can't disable output
escaping for an attribute value):

   <xsl:text disable-output-escaping="yes">
      &lt;input type="hidden" name="ProductID"
             value="&lt;%=request.getParameter(\"productid\")%>">
   </xsl:text>

This will only work in processors that support disabling output
escaping, but I think most of them do.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • writing an xml with jsp
    • Java XML - Thu, 5 Apr 2001 10:15:25 -0400 (EDT)
      • <Possible follow-ups>
      • xml - Thu, 5 Apr 2001 10:57:55 -0400 (EDT)
        • Amit Khare - Thu, 5 Apr 2001 12:30:18 -0400 (EDT)
          • Jeni Tennison - Thu, 5 Apr 2001 13:19:00 -0400 (EDT) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.