Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java, HTML and XML

Posted on 2003-12-05
5
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

670 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