File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Which data type should I use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Which data type should I use?" Watch "Which data type should I use?" New topic
Author

Which data type should I use?

Hazel Sisson
Greenhorn

Joined: Feb 12, 2002
Posts: 17
Hi guys,
I am currently writing a web application that involves a section where users can submit code.
I was just wondering if anyone had any idea which data type/object I should use to store the code after it's submitted from the form? I will need to go write a loop to change " into \" so it can be stored in the database too, so something that would enable me to access each character is needed.
Thanks!
Hazel
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Check out the last post (mine) in this thread over in Servlets:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=007549

Basically, you don't need to worry about encoding the special characters (like & or ; or ") in a String when it is sent to your web application.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I've modified the code that I wrote back for that other thread:

HTML FORM
SERVLET (mapped to /encTest)
OUTPUTBasically, it doesn't look right on the *viewed* web page, because \n at the end of the lines doesn't equate to <br>'s in HTML. But otherwise, all special chars turn out ok.
Hazel Sisson
Greenhorn

Joined: Feb 12, 2002
Posts: 17
Thanks a lot, that's really helpful!
Hazel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which data type should I use?