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 JSP and the fly likes Problem with linefeed 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 » JSP
Bookmark "Problem with linefeed " Watch "Problem with linefeed " New topic
Author

Problem with linefeed

Kasi Gadde
Greenhorn

Joined: Aug 03, 2007
Posts: 3
Hi Guys,
I have a problem with linefeed character. In my application users entered data in the text box(JSP) and while saving in oracle database linefeed characters got appeneded to the data. Is there any chance we can enter linefeed character through JSP textbox. I am not able to re-produce the same. I appreciate any help.

Best Regards,
Kasi Gadde


Best Regards,<br />Kasi Gadde
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

Please do all of our eyes a favor and adjust your display name to be mixed or lower case. The all uppercase is rather jarring.

There is no way the user can enter a newline into a text input. Even if cut/paste is used, the browser will either truncate the paste at the newline, or substitute spaces for them.

Are you sure it's a text input that you're talking about? Text areas do allow newlines.
[ July 31, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

P.S. There is no such thing as a "JSP text box". It's all HTML.
Kasi Gadde
Greenhorn

Joined: Aug 03, 2007
Posts: 3
Thanks a lot. If I give tabs in the textbox then square boxes are appended to the string but as you said I am not able to enter new line characters.
Ofcourse its HTML text box, I accept friend.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

So where are the linefeeds (or newlines -- they're not the same character, by the way) coming from? It's highly unlikely they're coming from the form submit (here's an exercise: how can you find out for sure?). Looks like it's time to trace through your code finding the point at which the unwanted characters appear.
Kasi Gadde
Greenhorn

Joined: Aug 03, 2007
Posts: 3
Even I wanted to go through the code to find out from where this linefeed or newline has come. I am sure its a new line because when I copy that value from the table and paste it in the editor the cursor moved to the next line. Because of this day-end programs got failed. I will find sometime this week-end to go through the code. I am thankful for your replies.
Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
I have a textarea in a JSP which will display message data bytes as strings. This is an MQ message editor. What I'm finding is that if the bytes '0A' are present in the message data, they'll display the same as if the bytes are '0D 0A'.

Everything's fine until the user posts the form - then any end_of_lines (sorry if my wording's off) are translated to '0D 0A'. In the case where the original bytes were '0A' that means extra bytes are added to the message data.

Not sure if this is a java, encoding, or HTML issue (or none, or all

Any insight would be appreciated.

thanks,
Tom

(PS: Not to hijack this thread or anything, but I believe I'm having nearly the same issue, and rather than opening a new topic, thought I'd try in here since it's pretty recent - if bad form, please let me know.)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
Tom,

0D is a carriage return, while 0A is a linefeed (a.k.a newline). While Unix uses only a linefeed to indicate a line break, Windows uses a carriage return followed by a linefeed. So you may well see both versions in different places, although they really mean the same thing. Most applications understand this problem, and can work with either variant, but some still don't.

I can't tell from your post whether this is causing an actual problem, though, or if it's just a nuisance.
[ August 15, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
Thanks Ulf, Yes, I'm learning a lot about control characters today.

It is more than a nuisance since the actual data length of the message is changed when this occurs. There is also a hex editor that when used, can deal correctly with the values. It's just an issue that the textarea, when posted, converts any line breaks into the CR/LF version. Currently it has no way to know what the original bytes were. I"m wondering if my pageEncoding value, if changed, could alter this behavior. Maybe base it off the MQMD.Encoding value of the original message.
[ August 15, 2008: Message edited by: Tom Katz ]
 
jQuery in Action, 2nd edition
 
subject: Problem with linefeed
 
Similar Threads
comment problem
K&B Study Guide for Java 5 p498 Selftest problem 1
carriage ret & linefeed
Tomcat swallowing SQLException
Japanese character not read or written correctly