This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes formatting the textarea form field in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "formatting the textarea form field in a servlet" Watch "formatting the textarea form field in a servlet" New topic
Author

formatting the textarea form field in a servlet

Ulvi Cetin
Ranch Hand

Joined: Mar 03, 2003
Posts: 39
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 ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulvi Cetin
Ranch Hand

Joined: Mar 03, 2003
Posts: 39
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Please post the code for your textarea in a topic in the HTML forum.
hth,
bear
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Tell you what, I will just move this to the html forum.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: formatting the textarea form field in a servlet
 
Similar Threads
maintainig carriage returns
Old Form Bean data VS New Form Bean Data
formatting text output from database
displaying long strings
formatting the textarea form field in a servlet