• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

textarea

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I enter a text like this (in the textarea) :
aaaaaaa
bbbbb
cccccc
I want to save this in the database(mysql) an then, read from db and put on the screen(webpage) exactly as i entered in the textarea (with the newlines,etc.). How can i do that? .. because when a read from db and put on the screen the text looks like this: aaaaaabbbbbbccccc...THNX!...( i don't want to use html tags( like .<br>.) when i enter the text)
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not a servlet question, it's an HTML formatting issue.
The easiest way to do it is to output the data between presentation tags <pre></pre>, or you can look at CSS and find the style settings to retain formatting. The default in HTML is to treat it all as white space and ignore it.
BUT that's only if the line feeds are being retained in the database. It would be worth checking the data to make sure it's being retained correctly first.
Dave.
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Iam facing the problem of how to store newlines in sqlserver database from a jsp page which gets data from a textarea in a html page. Can anyone suggest how to store newlines in a sqlserver database.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure they are the same problem. Relu, did this help?
'ch', your post may be better in the JDBC firum, but I can't move this thread there because of the original post. Can you post some of your code?
Dave
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
my suggestion is, use substring on the textarea string and put in individual columns, hence when you retrieve you can easily modify your output as you want.
hope this helps.
regards,
ravi
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that when you enter the text in a textarea, new lines are in fact return characters. HTML does not use the return character to display text on a new line. What I do to solve this problem is replace all '\n' characters with a string containing "<br>". This will format your text the way you want in html. I also remove all '\r' characters since you no longer need that character.
Hope this helps.
-Chris
 
Relu Ovidiu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The <pre> </pre> it's working (..for the moment)... THNX a lot! ...
 
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic