Prevent HTML Decoding on Form Values - character-encoding

I have a form element such as:
<input type="text" value="O’Reilly" />
But when this form is submitted, the value passed to the form handler is decoded and the ’ character is sent instead of the original string ’
I need to get the original string in it's literal/raw form, but I cannot seem to force the page to stop decoding these HTML elements for me. Any ideas?

HTML-encode the ampersand with & to prevent it from being part of an escape sequence: <input type="text" value="O&rsquo;Reilly" />

Related

Browser ignores query string

I have a hardware device with an admin console accessed via a web interface. I want to pass a query string to the URL so that the username and password fields are pre-populated. I am doing so as follows but the browser ignores the query string:
http://192.168.5.50?username=abc?password=def
I have checked the page source and the username and password input fields are called "username" and "password".
EDIT:
I see that I have incorrectly used the character ? instead of & to separate the key/value pairs. Correcting this as follows does not change the outcome. The query string is still ignored.
http://192.168.5.50?username=abc&password=def
There is a form in the HTML with this definition:
<form name="myform" method="post" action="read" autocomplete="off">
Is the POST method incompatible with query strings? If so, is there another method of auto-populating fields?
You can try to create a form dynamically and submit it. You url should be something like this:
javascript:document.write('<form name="myform" method="post" action="read" autocomplete="off"><<input type="hidden" name="username" value="abc"><input type="hidden" name="password" value="def"></form><scr'+'ipt type="text/javascript">document.getElementsByTagName("form")[0].submit();</scr'+'ipt>');

Insert text with space from resource file to the value property of input in MVC 4

I have the following code to insert text from resource file to the value property of input in MVC 4:
<input type="submit" value=#EXAMPLE.Resources.Account.Login.SignInText />
The text is in spanish: "Iniciar Sesion", however only shows "Iniciar" because between "Iniciar" and "Sesion" exist one space character.
Any Idea?
Thanks,
Add quotes around your attribute value:
<input type="submit" value="#EXAMPLE.Resources.Account.Login.SignInText" />
You should ALWAYS use quotes for attributes IMHO, don't omit them.

Rails form helpers errors html

When I create a form with form helpers and put it in invalid data, the fields that get added by the error tags get put all between quotes and a see in the html the following:
"<span class="fieldWithErrors"><label for="email">Email</label></span> <span class="fieldWithErrors"><input id="email" name="email" size="30" type="text" value="adfasd" /></span>"
Note the quotes around the whole text which means this is the actual text when browsing from a website.
The messages on top appear to be correct but for some reason, it adds these quotes around it all. Any idea why?

Can i use html tags in struts2 form?

Can i use html form tags in struts 2 form?
Like
<input type='text' value='' />
<input type='submit' />
Will the values be posted through struts2?
It's not at all mandatory to use struts2 tags. You could go with regular HTML.
Of course.
This is one of those questions you can just try.
All the S2 form tags do is emit HTML, filling in various attributes as required. (It's slightly more complicated than that, but ultimately, they spit out an HTML form field.)
Flip your question on its head: why wouldn't a hand-crafted input tag be sent via the normal browser HTTP submission process? What mechanism could prevent it from working? How is the request body of from such a form submission different from one where the input tags are S2 custom tags?
These questions are all trivial to explore.
Yes.
You must give them a name; the name will be used to set properties (with correct type conversion) in the struts action.
If you call an input somename the setSomename() will be called on post.
If simple HTML used you wont be able to call struts tags inside it eg:
<s:submit cssStyle="submit_button" id='newrc%{#stat.index}.%{#questionIndex.index}' name="newrc%{#stat.index}.%{#questionIndex.index}" onclick="return newrcClick(this)" value="+" />
This works but below code does not provide values for id and name from values stack thus :name="newrc%{#stat.index}.%{#questionIndex.index}"
<input type="button" cssStyle="submit_button" id='newrc%{#stat.index}.%{#questionIndex.index}' name="newrc%{#stat.index}.%{#questionIndex.index}" onclick="return newrcClick(this)" value="+" />

Problem while retrieving hidden parameter with CXML text as value from Struts2 Project to Simple JSP project

Am passing a cxml document text from Servlet to JSP in struts2 and the jsp will submit form BODY onload with action = "to Second Project" also the same cxml text been passed in hidden parameter and its working fine, but when i try receive the value of parameter passed from first Project its in-complete only i have got first 15 characters -->
I think you are using you are using <input type="hidden" value="" /> and your parameter also got double quote. Try to user value=''

Resources