Assign HTML character entities

Hello,
I have a scenario where a message should be sent to an HTTP server using the HTTP receiver CC. In the message itself no special HTML characters such as <, > or / should be used but they should be replaced with special character entities such as &lt for < .
Is there an easy way to do this as it is quite a common requirement? Is there an adapter module available for this or must this be done in the mapping itself?
Thank you for your advice.
Edited by: Florian Guppenberger on Aug 11, 2009 6:54 PM
Edited by: Florian Guppenberger on Aug 11, 2009 6:55 PM

> public void execute(InputStream in, OutputStream out)
>           throws StreamTransformationException {
> try{   
> int c;
>     while ((c = in.read()) != -1) {
>       switch (c){      
>          case '&': out.write("&amp ;".getBytes()); break;   
>          case '&lt;': out.write("&lt ;".getBytes()); break;
>          case '>': out.write("&gt ;".getBytes()); break;
>          default: out.write(c);
>        }
>
>     }
>   } catch (IOException e) {
>     throw new StreamTransformationException(e.getMessage());
>   }
>
>
> }
The SDN forum does not allow html escape sequences, so I put a space before the ; which you have to remove in your code.
' and " need not to be escaped, so I removed that lines.
Edited by: Stefan Grube on Aug 16, 2009 11:06 PM

Similar Messages

  • Rendering text that contains old-style HTML character entities, e.g. ü

    The large text-corpus I'm working with was produced before the days of widespread Unicode support, and it contains HTML character entities instead of unicode codepoints, e.g. &uuml; for ü [u-umlaut].
    I can iterate through every text column in the ArrayCollections that I'm using for dataProviders to the DataGrid, and replace these entities with their unicode counterparts before the provider is assigned to the grid. But is there already a mechanism in place in Flex to render character entities in the DataGrid? Is there a ready-made ItemRenderer that can do this?
    Thanks

    DrClap wrote:
    So your example looks like this?
    <someNode>der fuchs springt &#252;ber den stein</someNode>
    now I feel stupid :-) Yes, that's correct.
    And you're actually getting an EntityReference node in your Document? I find that rather strange, since the documentation for EntityReference says
    Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference.
    Exactly!
    Because what you have there is a character reference. Is there something else in the document, a DTD for example, which might be interfering with that?No, just an ordinary XML header:
    <?xml version="1.0" encoding="UTF-8"?> ...If it helps, I can also post the complete document I am receiving.

  • Weblogic xss vulnerablity : html character entities getting decoded in jsp by ${} expression

    This is from my question at stack overflow java - Weblogic xss vulnerablity : html character entities getting decoded in jsp - Stack Overflow
    I am using a filter to prevent xss by encoding html character of my jsp form parameters.
    I am resolving them in jsp using ${param} expression.
    This is working fine in tomcat as the values are resolved as is, but on weblogic the values are getting decoded, causing the XSS to succeed
    I am using this simple code in jsp to test it
    <c:set var="testing" value="eb011&quot;&gt;&lt;img src=a onerror=confirm(1)&gt;47379"/> <input type="hidden" name="encoding" value="${testing }"/>
    Result in tomcat
    <input type="hidden" onerror="confirm(1)&gt;47379&quot;/" src="a" &gt;&lt;img="" value="eb011" name="encoding">
    Result in weblogic
    <input type="hidden" value="eb011" name="encoding"><img onerror="confirm(1)" src="a">47379"/&gt;
    why is weblogic decoding html codes and what could be done to prevent it.

    It is really handy to learn how to read schema validation errors. It really does say exactly what's wrong there. If you can get access to the XSD that your XML document is prescribing, you should be able to tell what mistake you made. If you learn how to do this, you'll never have to ask questions like this again. :)
    The error refers to the "http://www.bea.com/ns/weblogic/weblogic-web-app" namespace, which I believe is in your "weblogic.xml" file. It's saying that in the "jsp-descriptor" element, it found a "noTryBlocks" element at a point where it was not legal. At that point, it expected to find either a "'precompile-continue" or several other elements, but not that one. Read the XSD to determine the correct order for elements. If you're editing this file in Eclipse, you may not even have to obtain the XSD. If you hover the mouse over the root element of the document, it will give you a popup showing the syntax details of the element, which will tell you what the expected order of elements is.

  • How do I display Tools Developer Page Source without HTML Character Entities, such as & and

    I am using Firefox 8.0 on Windows XP. In earlier versions of Firefox, when I would display the page source, the page would be displayed in all its original characters, including < > & and so on (including the HTML reserved characters.)
    Now when I display page source, the page source is displayed, but instead of displaying html tags,
    <p> for example,
    it will display &lt;p&gt; in the source instead.
    For a longer example, instead of displaying
    <p class="stuff">text to display</p>
    the source is rendered as
    &lt;p class=&quot;stuff&quot;&gt;text to display&lt;/p&gt;
    Is there a way to direct Firefox to display page source using all actual characters instead of using character entities?

    Clarification.
    The html tags render until it encounters this code:
    <input id="htmlHidden" type="hidden" value="&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;
    &amp;lt;div id=&amp;quot;content-inside&amp;quot;&amp;gt;
    &amp;lt;div id=&amp;quot;content-space&amp;quot;&amp;gt;
    &amp;lt;div id=&amp;quot;about&amp;quot; class=&amp;quot;node&amp;quot;&amp;gt;
    &amp;lt;div class=&amp;quot;node-inner&amp;quot;&amp;gt;...

  • Displaying HTML character entities in JEditorPane

    Hi,
    I have noticed that when displaying HTML character entity references in a JEditorPane it will show some of them, e.g. &copy; for copyright symbol but not others e.g. &rsquo; for "curly" single quote.
    Is there any way to get JEditorPane to show all (most?) of them?

    Create a class that extends ComboBox and override the
    updateDisplayList and measureText functions. Then use that new
    ComboBox in your code:
    <local:HtmlComboBox .. xmlns:local="components.*".>
    <local:itemRenderer>
    <mx:Component>
    <mx:Text htmlText="{data.label}" />
    </mx:Component>
    </local:itemRenderer>
    </local:HtmlComboBox>
    Put this into a folder called "components" and name the file
    HtmlComboBox.as
    package components
    import mx.controls.ComboBox;
    import flash.text.TextLineMetrics;
    public class HtmlComboBox extends ComboBox
    public function HtmlComboBox()
    super();
    override protected function
    updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    super.updateDisplayList(unscaledWidth,unscaledHeight);
    var s:String = textInput.text;
    textInput.htmlText = s;
    override public function
    measureText(text:String):TextLineMetrics
    return measureHTMLText(text);
    }

  • HTML character entities problem in saved regex search and replace query

    I have a many search and replace regular expression queries (.dwr files) that I have saved. I have a problem specifically with saved queries that contain HTML entities such as "& nbsp ; " or "& shy ;" (spaces added otherwise code doesn't render in browser). For example if I use the following search:
    ([\d]{3}& shy ;[\d]{3}& shy ;[\d]{4}|[\d]{3}& nbsp ;[\d]{3}& nbsp ;[\d]{4})
    (which searches for numbers in the 888-555-1234 or 888 555 1234 formats)
    This will work fine if I manually enter it into the search text area. However if I save it to file and reload it, it will no longer work because the &shy; and   characters are now displayed as " " (space) and "-"(shy) rendering the saved query useless as it's no longer searching for the code. I have some fairly long and complex queries and this is becoming a problem.
    Thanks for any help.
    I'm currently using Dreaweaver CS4 at home and CS5.5 at work.

    Thanks for your reply Kenneth, but that is not what I'm trying to accomplish. I'm looking for the HTML entities that exist in the source code which are & shy ; and & nbsp ; (without the spaces). As I mentioned above, if I enter them manually in the search box, I will get the corrrect results. If I save the search and then reload it, the special characters are no longer in HTML and the search is now useless.
    Just for example again
    In an open document in code view insert a number in the format (without the spaces): 888& nbsp;888& nbsp ;8888
    Open a search dialog box and enter (without the spaces): [\d]{3}& nbsp ;[\d]{3}& nbsp ;[\d]{4}
    The search will find that entry.
    Save search as phone.dwr for example. Then load it and try the search again. It won't work because upon loading the search Dreamweaver replaces the HTML code which was saved with the rendered HTML. So now the search shows up as: [\d]{3} [\d]{3} [\d]{4} which will not find the string with hard coded non-breaking spaces that I'm looking for.
    Basically I want to be able to save a search query for reuse. When I load a search query, I want it to be exactly what I saved, not something that DW has rendered (that doesn't work).

  • Displaying Numeric Character Entities

    I�m having a problem displaying numeric character entities such as ��� (m-dash) in my Java application. I have noticed that some characters will show up correctly and some will not, for example �}� (Right curly brace) shows up just fine. I�m having the same problem with Japanese numeric character entities such as �&#24335;�. The encoding that is being used here is UTF-8.
    I am reading the text that contains these entities from a XML file using the following code:
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setIgnoringComments(true);
        dbf.setIgnoringElementContentWhitespace(true);
        try {
          FileInputStream fff = new FileInputStream(theFile);
          InputSource inSource = new InputSource(new InputStreamReader(fff,"UTF-8"));
          DocumentBuilder db = dbf.newDocumentBuilder();
          Document doc = db.parse(inSource);
        } catch (Exception e) {
          System.out.println("Exception: " + e);
        }Here is a simple example of an xml file.
    <?xml version="1.0" encoding="UTF-8"?>
    <toc name="Course One" file="course1/toc.xml">
    <topic name="Topic � One" file="course1/source/topic1.html"/>
    <topic name="&#24335; (Japanese char)" file="course1/source/topic2.html"/>
    </toc>When I print out the contents of the name attribute I get boxes (or a ?) in place of the character entity. Any help that can be offered here would be greatly appreciated.
    Thanks,
    David

    I just realized that the entities that I put in my post were resolved by the browser, so they didn't show up as the actual numeric entity code as I intended, &#151; (& + #151;) for m-dash &#125; (& + #125;) for the curly brace and &#24335; (& + #24335;) for the Japanese character. The XML file looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <toc name="Course One" file="course1/toc.xml">
    <topic name="Topic &#151; One" file="course1/source/topic1.html"/>
    <topic name="&#24335; (Japanese char)" file="course1/source/topic2.html"/>
    </toc>

  • Handling Character Entities - Java Mapping Issue

    Hi Experts,
        I need to replace the character entities in my input XML. But, the problem is the java mapping I've written isn't replacing  the character entities as expected.  For example if my input XML  contains <NAME>&><XYZ</NAME>, then the ouput is <NAME>&amp:&gt:<0001&lt:/NAME>, whereas it should be <NAME>&amp:&gt:&lt:0001</NAME>.
    Note: I've used : instead of ; just to show it properly SDN.
    Can any of you share the code for the same if you've used it already?
    Thanks a lot in advance.
    Regards,
    Hussain.

    Hi Pooja,
        Thanks for your prompt reply.
    Are you trying to use the java mapping just to handle the character entities or your interface itself only has a java mapping?
                   - I'm using Java Mapping just to handle the character entities. Say my input XML looks like
    <?xml version="1.0" encoding="UTF-8"?>
    <resultset>
    <row>
    <ID>&<1</ID>
    <MESSAGE><![CDATA[<?xml version="1.0" encoding="UTF-8" ?><LGORT>&<0001</LGORT>]]></MESSAGE>
    </row>
    </resultset>
    I need to replace &< in <ID> to &amp:&lt: and similarly for CDATA <LGORT>&amp:&lt:0001</LGORT> before I process it in XI. In my java mapping I read the whole XML as string (line by line as mentioned below) and try to replace the character entities using some logic, which isn't working properly.
    StringBuffer buffer = new StringBuffer();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
    for (String lineRead = reader.readLine(); lineRead != null; lineRead = reader.readLine()) {
           buffer.append(lineRead);
    I've also checked the thread mentioned by Srinivas. But, StringEscapeUtils.escapeXml() would replace all the character entities like &lt:?XML... , which would result in an invalid xml...
    Please suggest.
    Thanks,
    Hussain.

  • Assigning a Character in a String

    Looking to assign a character in a string but it looks like
    charAt is read only? Ideas?

    + is not a syntactic rule about source line
    continuation, it is rather invoking a String
    operator.
    This works due to the source line continuation if C:
    #include <stdio.h>
    int main() {
    printf("%s\n", "MMMEEEIII \
    OOMMMEI");
    I'm on this ice here, but isn't that done by the preprocessor, and is thus not a part of the C programming language?
    You can use a preprocessor on the Java language as well if you want to.
    Kaj

  • HTML Character entity references on SQLQuery

    I am trying retrieve the data thru XMLElement and I like to do a HTML Character entity references. I guess XMLElement does it with the proper character set translations and I was not successul in getting it correct. Could you please help me out. My DB character set it UTF-8.
    For example, the "acute" e needs to be translated to its hexa equivalent. I tried it by setting the mid-tier's client's NLS but with no success. I dont want to scan the each character and convert it.
    create table master.temp_xml_encode
    (party_name_id NUMBER(15),
    party_id NUMBER(15),
    party_name VARCHAR2(200) );
    PARTY_NAME_ID PARTY_ID PARTY_NAME
    3831587 5496840 The West Company México, S.A. de C.V.
    3844362 5496730 Schiønning & Arvé A/S
    3847940 5496836 West Rubber de España, S.A.
    4047634 5983166 Timberland España, S.L.
    4266163 5983166 Timberland España, S.A.
    4285954 6482794 The Young Women¿s Christian Association of Central New Jersey
    SELECT XMLELEMENT("party_id", party_id,
    xmlforest(party_name_id AS "partynameid",
    party_name AS "partyname"
    FROM master.temp_xml_encode
    Thanks for your help

    And Yes forgot to add one thing, the index.jsp is a part of the application supplied by vendor and I do not have src of the struts actions (no control on server side code).
    I need to find a solution from client's side.

  • Character Entities - too SMALL

    Is there any way to change the font size for the drop down
    help menu when typing character entities? I have tried changing the
    code view point size but the help menu remains the same size no
    matter what...
    Just to clarify, I am not asking how to change the point size
    of the document - just the drop down dialog box that allows you to
    chose which character entity you want to select.
    Thanks!

    > Is there anyone from Adobe that actually responds to
    these posts?? My
    > original
    > question had to do with the preferences in Dreamweaver,
    not hacking away
    > through my system preferences.
    Rarely. This is a user to user forum, not an official
    communication link to
    Adobe.
    If you need to communicate directly with Adobe, you would
    have to contact
    them directly.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "eperkins21" <[email protected]> wrote in
    message
    news:g6o1f8$peu$[email protected]..
    > Is there anyone from Adobe that actually responds to
    these posts?? My
    > original
    > question had to do with the preferences in Dreamweaver,
    not hacking away
    > through my system preferences.
    >
    > So, thanks *ACE* but unless you know exactly how to
    answer the question
    > using
    > the system preferences, that post is of no help.
    >
    > I find it hard to believe that you can change the font
    size of the
    > document
    > for those who may be visually impaired yet the drop down
    character entity
    > help
    > list remains around 8 points and can not be modified
    without going to
    > "system
    > preferences".
    >
    > How about someone from Adobe actually help out here...
    >
    > Thanks.
    >

  • Convert from HTML Character Codes in Applescript

    Hey everyone,
    I have an applescript that retrieves some info from websites, but sometimes parts of the information are encoded into HTML Character codes for web compatibility. Could someone point me in the right direction to processing these into plain simple text? Has somebody already written a tool? Sorry, I'm very new to this, but willing to learn.
    Thanks in advance.
    Jason

    This should to the job. Thx apple =)!
    <pre style="margin: 0px; border: 1px solid #aaa; width: 800px; color:#000; background-color: #ccc; overflow: auto; font-family: Verdana, Monaco, monospace;"> set web_url to quoted form of "http://discussions.apple.com/thread.jspa?threadID=2244400&tstart=0"
    *do shell script* "curl " & web_url & " | textutil -stdin -convert txt -format html -stdout"</pre>

  • List of ADE supported character entities?

    Is there a list of all the XHTML character entities supported in Adobe Digital Editions? I have an .epub book of poetry that uses a lot of &#8195; (em spaces) which just render as a question mark (?) in ADE. Trying to figure out my options, but surprisingly, can't seem to find a source.

    @TM1970, I ended up making a sample EPUB with various characters and typle styles that I could then upload into ADE and other readers to test the rendering. I posted it on our website if you'd like to download it at: http://www.holartbooks.com/documents/miscellaneous/EPUBStyleGuide.epub But basically, ADE seemed to support everything but the three spaces -- thin space, en space, em space. Hope that helps.

  • Error while assigning a character value to a numeric variable.

    I fire a sql statement and check the number of rows returned by the sql.
    I check this result with the application logs.
    The application logs keeps the sqls fired by the application and the no of rows returned, in the example below the sql returned 8454 rows.
    My script compares the two results.
    ***********Application Log***********
    4/14/2008 11:15:01 AM: 0059 SQL SELECT "CLUSTER_CD",
    4/14/2008 11:15:01 AM: 0060 "PRODUCT_DESC",
    4/14/2008 11:15:01 AM: 0061 "TEAM_CD"
    4/14/2008 11:15:01 AM: 0062 FROM "OPS$TMS"."MAP_CLUSTER_TEAM_PROD"
    4/14/2008 11:15:01 AM:      3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD, 8,454 lines fetched
    ***********Application Log***********
    My script:
    #!/bin/ksh
    typeset -i resA
    typeset -i resB
    opstms_conn_string="abc/[email protected]"
    set `sqlplus -s $opstms_conn_string << EOF
    set pages 0
    WHENEVER SQLERROR CONTINUE
    SELECT count(*)
    FROM MAP_CLUSTER_TEAM_PROD;
    exit
    EOF`
    resA=$1 ##returns 8454
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{print $10}'`
    ##resB returns 8,454
    ## here i get syntax error
    if [ $resA -eq $resB ]; then
    echo "QA passed for sql1"
    else
    echo "QA failed for sql1"
    fi
    The problem is as resB is integer variable it does not accept character value: 8,454 so returns a syntax error:
    How do I change the value assigned to resB into a numeric variable?
    error:
    + grep 3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD, BCVP_Main_Loader.qvw.log
    run.ksh[52]: 8,454: syntax error

    Change:
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{print $10}'`
    to this:
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{print $10}' | tr -d ,`
    to drop the comma. Or you could do it in awk(1):
    resB=`grep '3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD,' BCVP_Main_Loader.qvw.log | awk '{ gsub( /,/, "", $10 ); print $10}'`
    Or you could to it all in awk(1):
    resB=`awk '
    /3 fields found: CLUSTER_CD, PRODUCT_DESC, TEAM_CD/ {
    gsub( /,/, "", $10 )
    print $10
    ' BCVP_Main_Loader.qvw.log`
    (This example was not tested, it's just for a model.)
    Someone more of an SQL guru than I can probably tell you how to change your numeric locale to avoid presenting those commas in the first place and avoid the problem.
    HTH

  • Assigning html input value to a jsp variable

    I have the following problem: I need to assign the value of html <input> field to a jsp variable. This should be done without submittion of the form.
    <form name="main">
    <table>
    <tr>
    <td><input type="text" name="gantry" value="123"></td>
    </tr>
    <table>
    </form>
    Is there any way to access main.gantry.value from jsp and assign it to a variable? I tried
    <% prevGantry = main.gantry.value; %>
    but it didn't work, and the problem is not with parsong or initialisation. Please, can anyone help?
    Best regards, SoVa.

    No it can't be done. You are mixing up java with javascript.
    Java/JSP runs on the server end. Generates an HTML page and stops running.
    The page loads in the browser, and and can run javascript locally.
    The only way to run java code again is to go through the request/response process. ie submit a form, click a link, make an Ajax call...
    The only way to get a field from the screen into a java variable is via request.getParameter().

Maybe you are looking for

  • ThinkPad X130e Not Charging or Powering On

    Hello All, I have a ThinkPad X130e that won't power on or charge. I have performed the unplug the power cord and remove the battery trick but still nothing happens. The thing is essentially a paperweight. Any ideas as to what else I can try is grealt

  • Behaviour of Hidden Key figures in MDX universe

    Hello Experts, I would like to know about the behaviour of Hidden objects in Bex query in an MDX universe. SAP BW environment: BW 7.3 being tried against BI 4.0SP2 and BI 4.0,SP4 and higher. In a 4.0,SP2 environment, when the display of an object is

  • Milestone billing to one delivery

    Hello, I've got following problem. To an SD-order position there is only one delivery, which should be billed within more invoices. These values should come into the COPA through the invoice - recort type F. So with the first invoice, also the costs

  • MM Excise Tables for PO Print

    Dear SAP Gurus, I am creating a PO with a taxcode containing BED, ECS,SCess and VAT.Po is saved and released.Now I am taking a PO Print but our ABAPER is not getting any table containing BED, ECS,SCess and VAT values and percentages without doing MIG

  • Why use channels

    I have worked in photoshop since photoshop 5 and even way back then I'd never gotten into the habit of using channels. At the time I think there were file size issues because I always used layers which would balloon out to quite large files, but I re