Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unnable to get the return key from jsp  RSS feed

 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am sending some text using text area from jsp .
the text contains return key. (new line)

while retriving i am displaying it to the console it is not diplaying the exact format which i have entered the text in the text area..

i have also used some logic to break the line in the servlet


public String checkForLineBreaks ( String str ) {
char ch;
StringBuffer sb = new StringBuffer(str);
for ( int i = 0; i < sb.length(); i++ ){
ch = sb.charAt(i);
if(ch == '\r'){
sb.insert(i,"<br>");
}
}
return sb.toString();
}

I think the problem is in jsp file coz it is not sending the retun key to the servlet after submitting the form

plzzz anybody help meeeeeeee
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by saikrishna cinux:

ch = sb.charAt(i);
if(ch == '\r'){
sb.insert(i,"<br>");
}


Take ASCII value of character and compare it with the ASCII value of the return key.

It will solve your problem.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ASCII Value Finder
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!