• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hanlde control characters in Servlet

 
Ravi Kumar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Please let me know how to handle control characters in Servlet. I have developed a fileupload screen which filename is "TT11.txt". While saving the file is saved properly in the database. If i try to open the screen, the screen loading is failing beacuse of control characters. Please let me know how to handle this issue.

Thanks
Ravi
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are going to have to change the characters to something legal before saving the file. The simplest thing to do would be to construct a new String for the filename by walking through the input file name one character at a time and substituting.

Bill
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Handle what control characters, and handle them how? Personally, I don't think a text file should *have* control characters in it.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some control characters such as crlf are expected in text files.

If i try to open the screen, the screen loading is failing beacuse of control characters.


If this was my problem I would open the file in my programmer's editor (UltraEdit-32) which can display the hex values. I would then look for values outside the normal printing character range and not cr or lf. If the file was created or modified using MS Word you may have those ghastly "smart punctuation" characters which are above the 7bit ascii range.

What exactly does "open the screen" mean anyway?

Bill
 
Ravi Kumar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly does "open the screen" mean anyway?

I have developed a UI page which is having one text box and Upload button. On click of upload button iam able to attach the file and able to save in database. If i have entered all english characters in the filename it is saving properly in db and screen is able to open properly(Contains texbox,upload button). But if i have given control characters in filename the file is saving properly in db, but fails in loading(Blank screen is loading).

Thanks
Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic