Solved

Java, HTML and XML

Posted on 2003-12-05
5
227 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 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
swing controls 2 37
Java class and jar 3 59
passing enum to a method 4 48
Testing site for http code 200 or curl equiv for Windows 2 97
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

732 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