aspose file tools*
The moose likes Servlets and the fly likes Hanlde control characters in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Hanlde control characters in Servlet" Watch "Hanlde control characters in Servlet" New topic
Author

Hanlde control characters in Servlet

Ravi Kumar
Greenhorn

Joined: Aug 28, 2008
Posts: 18
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

Joined: Mar 22, 2000
Posts: 12678
    
    5
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

Java Resources at www.wbrogden.com
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 22, 2000
Posts: 12678
    
    5
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

Joined: Aug 28, 2008
Posts: 18
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hanlde control characters in Servlet
 
Similar Threads
How to control the order in which a servlet instance is created
Java Help popup
Need some help regarding arraylist
downloading image
newline issues with J2ME?