• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to store the newlines entered by enter key in textarea?

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to store the text entered in a TEXTAREA control in the database, and retrieve when ever required.
Here the problem is It is not storing the new line characters (enter key), it is storing all the lines as ONE sentence.
I tried using different values for wrap attribute.(soft, hard, physical,virtual, etc), but no use.

Please help in this regard.
Thank you.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you reading, storing, and writing the value out?

Eric
 
M K Rayapudi
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:How are you reading, storing, and writing the value out?

Eric


I am using the javascript as follows:
 
M K Rayapudi
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still the problem not resolved
Please help .
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For HML, a newline character is just whitespace, and will be displayed as a space character. If you want an actual line break to appear on the HTML page,. you'll need to convert all newline characters to "<br/>" before displaying them.
 
M K Rayapudi
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Dittmer.
I need to store the content from the TEXTAREA in the table
and retrieve the same from TABLE and populate into that TEXTAREA.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It is not storing the new line characters


At which point along the code are the newline characters dropped? Are they still present when the servlet receives the form? Are they present in the DB? Are they present when the data is retrieved from the DB? Are they present when the JSP with the TEXTAREA is created?
 
M K Rayapudi
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

It is not storing the new line characters


At which point along the code are the newline characters dropped?


While storing into the table.

I am retrieving the form data in a servlet using request.getParamter(); if I print the content of the TEXTAREA character by character as int by casting , it is showing new line as 13 & 10 (two characters). After this I am storing this value in a TABLE, in the table it is storing as one string instead multiple lines (means no special characters are stored at the new line character positions)
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you should dig into the DB connectivity to see why it's dropping those characters. SQL and JDBC don't arbitrarily alter data they're handling, so some other piece of code may be involved.
 
moose poop looks like football shaped elk poop. About the size of this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic