Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which data type should I use?

 
Hazel Sisson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, that's really helpful!
Hazel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic