I am working on a web app, where a EXTJS makes an ajax call to a JSP, the JSP in turn calls a java class and then returns the value and updates something in the database.
now the question is, I somehow do not feel this is an effective way, I discovered about servets working and was wondering if should just make a Ajax call to the servlet instead of JSP. Are there any other ways which are better and optimized. Please explain.
Thanks,
SixthString
It depends on what you want returned form your Ajax call. JSP is used for generating formatted HTML. If that’s what you’re looking to get from the Ajax call, then JSP could be the right choice.
If you’re looking for some raw data, then you might as well skip the JSP template and go straight to the servlet. I recommend using JSON in this case, because it’s easy to work with in JavaScript.