Solved

Java, HTML and XML

Posted on 2003-12-05
5
224 Views
Last Modified: 2013-11-24
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.

e.g

Should be:  <node1>myvalue<br>myvalue2</node1>

Currently: <node1>myvalue
                        myvalues2</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.
0
Comment
Question by:fayeb
  • 3
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 9885307
s.replaceAll("\n", "<br>");
0
 
LVL 92

Expert Comment

by:objects
ID: 9885325
Have you thought of using XSL to generate the HTML from the XML?
0
 
LVL 3

Expert Comment

by:applekanna
ID: 9885390
this is not exactly your solution but the problem and solution idea here is the same

http://oldlook-search.experts-exchange.com/Web/Web_Languages/JSP/Q_20791591.html
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9886166
If that node can contain a line break, it must be <br /> as <br> would not be well-formed XML.
0
 
LVL 92

Expert Comment

by:objects
ID: 9916238
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question