• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

unnable to get the return key from jsp

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ASCII Value Finder
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic