in reply to HTTP within an application

What does Perl offer for this?

HTTP::Daemon will get you started.

What about other programming languages - is this how e.g. Javabeans work?

J2EE Entity and Session beans typically run within "containers" exist in an environment that has a built-in web server.