You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by tejz <gu...@gmail.com> on 2010/02/25 13:01:12 UTC

how to display text with \n,\r in jsp from textarea?

I am wondering as how all these sites (like this Expert-Exchange, hotmail,
etc etc) works which are able to show all 

kind of chars (KEEPING format) in your mail/postings. All these data are
entered in the TextField (like this one, 

where a I am typing this content), which goes to some database (like Oracle
in mycase). And then they are able to 

show the whole data back in some TextArea without any problem. I think if I
start taking care of each special char 

for me (like new line, ', " etc) then there could be no end for my code. I
believe there should be some mechanism by 

which whatever data you get from DB (Oracle) --> JSP Java String object -->
HTML TextArea and Vice-Versa without 

loosing any data and preventing the "Unterminated string constant". I
believe that some sort of encoding and 

decoding need to be done, but what those are? How all these sites do it.

Textarae:------

<tr>
<td>NOTES :-</td>
<td>&nbsp;&nbsp;&nbsp;<TEXTAREA Name="notes" rows="4"
cols="30"></TEXTAREA></td>
</tr>

JavaScript:----

var notes=document.Form.notes.value;
notes = notes.replace(/\n\r?/g, '<BR/>');

and saving it in db...as string..
and again retrivewing from db:------
notes = resultset.getString("notes"); 
notes = notes.replace("<BR/>","\n"); <--- is it corerect?

and displaying in jsp:----
<%
String notes =request.getAttribute("notes").toString();
out.println(notes);
%>


upto here ok....when i am edittng that notes in jsp as below:--
<tr>
<td>NOTES</td>
<td>:&nbsp;&nbsp;<html:textarea rows="6" 

cols="30"name="searchPrfForm" property="fprofilevo.notes"
styleId="notes"/></td>
</tr>

here also showing correct ,..but when i was click submit button..it was
showing error as unterminated string constant error..

on svae function:---
var notes=document.getElementById("notes").value;
notes = notes.replace(/\n\r?/g, '<BR/>'); 

plz tell me ..where i have to modify it?
how to display text with \n,\r in jsp from textarea? 

-- 
View this message in context: http://old.nabble.com/how-to-display-text-with-%5Cn%2C%5Cr-in-jsp-from-textarea--tp27714404p27714404.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: how to display text with \n,\r in jsp from textarea?

Posted by Erick Erickson <er...@gmail.com>.
Uhhhmmm, I admit I just scanned the first part of this e-mail, but is
the Lucene users list an appropriate venue for this?

Erick

On Thu, Feb 25, 2010 at 7:01 AM, tejz <gu...@gmail.com> wrote:

>
> I am wondering as how all these sites (like this Expert-Exchange, hotmail,
> etc etc) works which are able to show all
>
> kind of chars (KEEPING format) in your mail/postings. All these data are
> entered in the TextField (like this one,
>
> where a I am typing this content), which goes to some database (like Oracle
> in mycase). And then they are able to
>
> show the whole data back in some TextArea without any problem. I think if I
> start taking care of each special char
>
> for me (like new line, ', " etc) then there could be no end for my code. I
> believe there should be some mechanism by
>
> which whatever data you get from DB (Oracle) --> JSP Java String object -->
> HTML TextArea and Vice-Versa without
>
> loosing any data and preventing the "Unterminated string constant". I
> believe that some sort of encoding and
>
> decoding need to be done, but what those are? How all these sites do it.
>
> Textarae:------
>
> <tr>
> <td>NOTES :-</td>
> <td>&nbsp;&nbsp;&nbsp;<TEXTAREA Name="notes" rows="4"
> cols="30"></TEXTAREA></td>
> </tr>
>
> JavaScript:----
>
> var notes=document.Form.notes.value;
> notes = notes.replace(/\n\r?/g, '<BR/>');
>
> and saving it in db...as string..
> and again retrivewing from db:------
> notes = resultset.getString("notes");
> notes = notes.replace("<BR/>","\n"); <--- is it corerect?
>
> and displaying in jsp:----
> <%
> String notes =request.getAttribute("notes").toString();
> out.println(notes);
> %>
>
>
> upto here ok....when i am edittng that notes in jsp as below:--
> <tr>
> <td>NOTES</td>
> <td>:&nbsp;&nbsp;<html:textarea rows="6"
>
> cols="30"name="searchPrfForm" property="fprofilevo.notes"
> styleId="notes"/></td>
> </tr>
>
> here also showing correct ,..but when i was click submit button..it was
> showing error as unterminated string constant error..
>
> on svae function:---
> var notes=document.getElementById("notes").value;
> notes = notes.replace(/\n\r?/g, '<BR/>');
>
> plz tell me ..where i have to modify it?
> how to display text with \n,\r in jsp from textarea?
>
> --
> View this message in context:
> http://old.nabble.com/how-to-display-text-with-%5Cn%2C%5Cr-in-jsp-from-textarea--tp27714404p27714404.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>