Java, HTML and XML
Posted on 2003-12-05
I have web application which contains a questionnaire which users fill in and submit.
The questionnaire is generated by a Java servlet using an XML File for the structure.
When the user clicks on 'edit questionnaire', the java servlet is called. The servlet retrieves the XML files and reads the file into a vector. It then manipulates the vector to produce the the HTML questionnaire in edit mode for the user to complete.
Now here is where I am having trouble. On the questionnaire in edit mode is a number of textarea fields. If the user places a character return in the field to created a new line and saves the form, I need to capture this and place '<br>' in it place otherwise my XML file becomes invaid and it places the node values over two line which knocks all my code out.
Should be: <node1>myvalue<br>myvalue2</node1>
Does anybody know how I can capture the character return in a textarea field and replace it with the '<br>' value?
Thanks in advance.