replace "<" with "&lt;"

M

mark

I tried make my jsp files display about in browser by change their file
name extension to "txt" and
"encoding"/replacing all the "<" with "&lt;" and all the ">" with
"&gt;". I tried this


<replace dir="${deploy.path}/${name}/source/src/jsp"
value="&lt;">
<include name="**/*.txt"/>
<replacetoken><![CDATA[<]]></replacetoken>
</replace>
<replace dir="${deploy.path}/${name}/source/src/jsp"
value="&gt;">
<include name="**/*.txt"/>
<replacetoken><![CDATA[>]]></replacetoken>
</replace>

but found ANT just replace "<" with "<".

Any suggestion?

thanks

mark
 
M

mark

I found the post result itself was decoded. I reposted it below by
adding spaces
within those double quotes so that you can see them. So please ignore
spaces within double quotes when you read.
===============================================

I tried make my jsp files displayable in browser by change their file
name extension to "txt" and
"encoding"/replacing all the "<" with "& l t ;" and all the ">" with
"& g t ;". I tried this


<replace dir="${deploy.path}/${name}/source/src/jsp"
value="& l t ;">
<include name="**/*.txt"/>
<replacetoken><![CDATA[<]]></replacetoken>
</replace>
<replace dir="${deploy.path}/${name}/source/src/jsp"
value="& g t ;">
<include name="**/*.txt"/>
<replacetoken><![CDATA[>]]></replacetoken>
</replace>

but found ANT just replace "<" with "<" instead of "& l t ;" (please
ignore space within double quotes).

Any suggestion?

thanks

mark
 
A

Andrew Thompson

mark said:
I tried make my jsp files display about in browser by change their file
name extension to "txt" and

If they are being served up as text/plain (or whatever
the correct mime-type for text is), the '<' and '>' should
"encoding"/replacing all the "<" with "&lt;" and all the ">" with
"&gt;". I tried this

OTOH, if you want to serve them up as 'HTML', you
might try this..

<ant build snippet....>
<!-- ${htm} is our normal web page, but we
want to show the code. -->
<copy
file="${htm}"
tofile="${htm}.html"
/>
<replace file="${htm}.html"
value="&amp;lt;" >
<replacetoken><![CDATA[<]]></replacetoken>
</replace>
</ant build snippet....>

...by breaking up the '<' into an ampersand followed
by 'lt;', the character survives the initial conversion to
HTML.

HTH

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,269
Messages
2,571,097
Members
48,773
Latest member
Kaybee

Latest Threads

Top