• 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

formatting the textarea form field in a servlet

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a textarea field in an HTML form. When the user submits the form, a servlet inserts the content of the textarea in Oracle database.
When the contents of the textarea are retrieved from the database and displayed on a servlet or a JSP, line breaks and other formatting aren't displayed. I tried using the HTML PRE tag (preformatted), but that didn't fix the problem.
Any ideas on how to store the textarea in a database and/or how to display the retrieved contents from the database.
Thx.
Ulvi.
[ March 03, 2003: Message edited by: Ulvi Cetin ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with servlets really...
But other than line breaks, what kind are formatting are you talking about? Not much else is possible.
With regard to the line breaks themselves, are they coming back to you in the request parameter for the text area? If so, is something stripping them out going into or coming out of the DB?
The text area control has some funky behavior on various browsers, and there are a slew of non-standard wrap attributes that some older browsers supported but whose behavior is non-deterministic.
I'd suggest checking to see if the line breaks are being sent as part of the request parameter, and if not, reposting your question, along with the relevant HTML and handler code in the HTML forum.
hth,
bear
[ March 03, 2003: Message edited by: Bear Bibeault ]
 
Ulvi Cetin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, thanks for your reply!
I tried to view the contents of the textarea in the servlet (the one that is supposed to insert them into the database). I got the contents by request.getParameter("contents") and displayed them by out.println(contents) and I don't see line breaks in this output either.
So, as you suggested, I think something is stripping the line breaks (before they are inserted in the database) between the form page and the servlet. But what??
Thx.
Ulvi.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the code for your textarea in a topic in the HTML forum.
hth,
bear
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tell you what, I will just move this to the html forum.
 
Ranch Hand
Posts: 937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can format the text area using JavaScript
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The textarea sends the newlines as newlines, and when you print those out in a JSP or servlet, it appears that way (with the newlines) in the HTML source, but that won't mean it makes a newline on the browser window.

Have you tried replacing "\n" with "<br />"
 
Ulvi Cetin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply! I just figured out that just before you replyed. I needed to parse the text (with StringTokenizer) and replace all the "\n" with "<br>".
 
Straws are for suckers. Now suck on this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic