Why do we use servlets in AEM?
I am new to AEM. Till now I have been developing web applications using MEAN stack. The view was constructed using Angular, model is MongoDB and Controller part was handled by Node server.
Are servlets in AEM used to implement the controller part of web application? Like the data of a submitted form would be sent to the internal servlet which would communicate with the model to handle the data. If so, then wouldn't it be better to handle the controller logic separately as AEM should be used for the View part? Like writing the controller servlets in java and using some servlet container eg., Jboss and then submitting the form data to this REST endpoint.
Or are servlets only used for any front-end processing that we might require. In Angular this was achieved by the typescript code written in class file of component, a service or a directive (I can think of only these). If so, does this mean that in AEM we cannot write JavaScript or typescript code to be run at certain times and we have to use servlets only?