Rectangle 27 0

java Escaping HTML characters in JSP without special library?


Do NOT use SMS abbreviations when you are answering questions on this board. Type out the word "you"; be polite.

You can import org.apache.commons.lang.StringEscapeUtils and add its jar file. That are not by default present in jsp/servlets. It will provide you facility to escape characters from html, mysql, xml etc. Also you can make your own method to check for the character sequence and then use it as a escape function to escape data you want.

Note
Rectangle 27 0

java Escaping HTML characters in JSP without special library?


<%
String myString = "<b>Test</b>";
getPipelineDictionary().put("myDictKey", myString);
%>
<isprint value="#myDictKey#">
<isprint value="#value#" encoding="on|off">
<isset name="name" value="#value#" scope="request|session">
Map<String, Object> pdict = getPipelineDictionary();

A full example for usage with JSP/ISML would be:

Encoding is "on" by default and this statement will do exactly what you need: it will encode all HTML special characters in #value#. The special here is that the key value matches to an object in the so called Pipeline Dictionary which is a construct storing objects coming out of the Enfinity business logic workflow layer (so called pipelines).

Enfinity got an own "templating language" called ISML. In the end ISML is precompiled to JSP. You can find a documentation with any installation of the Enfinity application server (a PDF called enfsuite_dev_programming). You should ask your project manager or build engineer if you don't have it available.

Hi! Finally someone who can understand what program I was talking about! I was using the ISPRINT with the encoding ON, but some unencoded character are still passing through. If not, I would not freaking out searching for solution. My supervisor told me to use ISHTMLPRINT instead, but the same thing still happened. After lots of horrible trial n error, I finally resort to the most manual solution: creating my own custom ISML tag, because that allows me to use java library to solve this problem. But I learn something new from your answer as well. Thank you for your descriptive and clear answer!

However you get to the guide: in the appendix you find a section "Reference > ISML Tags / ISML Functions / ISML Modules". Browsing through it you will find the function:

If your target platform is really Enfinity - as you are stating in your questions and in the tags - you should be using the Enfinity constructs even though this is not completely what you know from JSP. Please allow me to reopen this old thread and try to help you with that.

On the other hand I read from your statement that you possibly have the Enfinity Studio available (which is the IDE of Enfinity - a derivate of Eclipse. You should be able to access the developer guide through Enfinity Studios Help Menu. This menu may have some errors in some versions of the Studio unfortunately. However, you can get there through Window > Show View > Other > Help. On bottom of the help window is a "Content" link that will take you to the overview. The developer guide is under the table of contents link Enfinity Suite Application Programming Guide.

The dictionary is a standard java Map and can be manipulated using the known operations. However, the preferred way would be using pipelines or at least the respective ISML tag

This pipeline dictionary can be manipulated in JSP using:

Note
Rectangle 27 0

java Escaping HTML characters in JSP without special library?


<%
String myString = "<b>Test</b>";
getPipelineDictionary().put("myDictKey", myString);
%>
<isprint value="#myDictKey#">
<isprint value="#value#" encoding="on|off">
<isset name="name" value="#value#" scope="request|session">
Map<String, Object> pdict = getPipelineDictionary();

A full example for usage with JSP/ISML would be:

Encoding is "on" by default and this statement will do exactly what you need: it will encode all HTML special characters in #value#. The special here is that the key value matches to an object in the so called Pipeline Dictionary which is a construct storing objects coming out of the Enfinity business logic workflow layer (so called pipelines).

Enfinity got an own "templating language" called ISML. In the end ISML is precompiled to JSP. You can find a documentation with any installation of the Enfinity application server (a PDF called enfsuite_dev_programming). You should ask your project manager or build engineer if you don't have it available.

Hi! Finally someone who can understand what program I was talking about! I was using the ISPRINT with the encoding ON, but some unencoded character are still passing through. If not, I would not freaking out searching for solution. My supervisor told me to use ISHTMLPRINT instead, but the same thing still happened. After lots of horrible trial n error, I finally resort to the most manual solution: creating my own custom ISML tag, because that allows me to use java library to solve this problem. But I learn something new from your answer as well. Thank you for your descriptive and clear answer!

However you get to the guide: in the appendix you find a section "Reference > ISML Tags / ISML Functions / ISML Modules". Browsing through it you will find the function:

If your target platform is really Enfinity - as you are stating in your questions and in the tags - you should be using the Enfinity constructs even though this is not completely what you know from JSP. Please allow me to reopen this old thread and try to help you with that.

On the other hand I read from your statement that you possibly have the Enfinity Studio available (which is the IDE of Enfinity - a derivate of Eclipse. You should be able to access the developer guide through Enfinity Studios Help Menu. This menu may have some errors in some versions of the Studio unfortunately. However, you can get there through Window > Show View > Other > Help. On bottom of the help window is a "Content" link that will take you to the overview. The developer guide is under the table of contents link Enfinity Suite Application Programming Guide.

The dictionary is a standard java Map and can be manipulated using the known operations. However, the preferred way would be using pipelines or at least the respective ISML tag

This pipeline dictionary can be manipulated in JSP using:

Note