Search code examples
websphereportletjsr286

Distinguish between '<' and the encoded equivalent using PortletRequest.getParameter()


I'm writing a JSR 286 portlet for IBM WebSphere Portal 6.1. I have the following code:

@ProcessAction(name="processForm")
public void processForm(ActionRequest request, ActionResponse response) 
    throws PortletException, IOException {    

    String formField1 = request.getParameter("formField1"));
    System.err.println("formField1: " + formField1);
}

If the user submits '<' on the HTML form, the system outputs:

formField1: '&lt;'

However, if the user submits '&lt;' on the HTML form, the system also outputs:

formField1: '&lt;'

This makes it impossible to determine which value the user actually typed into the HTML form. Is there a way around this?

I found an article here which recommends doing a straight replace, but it doesn't address the issue of distinguishing between the two different values on the form.


Solution

  • Can you see that '<' is arriving at the server, and it's not some other component that is altering the '<', such as the browser itself?

    If not, how about item 4 on this page (Problem: The "<" and ">" characters display incorrectly):

    http://publib.boulder.ibm.com/infocenter/wpdoc/v510/index.jsp?topic=/com.ibm.wp.ent.doc/wps/tbl_sec.html