Java and Javascript are totally different. If I were you, I'd do it in Java. Java, though not as powerful and C++, is quite powerful, and would be an excellent choice.
There already was work on a Java interpreter that plays real AGI games. If you learn Java, you could modify to be able to play actual AGI games with expanded web functionality.
On the flip side, if it's not going to actually be "AGI", then check out Indiana Java. It is a great engine.