As a premier example of a glorious and incredibly useful cnsole-like webapp, please see goosh, the Google Shell. I cannot imagine browsing the Net without it anymore.
Granted, there's no source code, but you might get out a bit of its magic by using Firebug or so.
Using a TextArea might be a bug-prone approach. Remember that you'll need to do both input and output to this TextArea and that you must thus keep track of cursor position. I would suggest that, if you really do this approach, you abstract away over a plain TextArea (inheritance, maybe?) and use a component that has, e.g. a prompt()
to show the prompt and enable input and a also follows the usual shell abstraction of having stdin
(an InputStream, that reads from the prompt, but can be bound to, let's say files or so) and stdout
and possibly stderr
, OutputStreams, bound to the TextArea's text.
It's not an easy task, and I don't know of any library to do it.