angular js benefits over jsp view

15,495

Solution 1

The biggest difference between Angular and JSP is where the work carried out - if you want a rich web application with lots of user interaction and page state, Angular may be the best choice. If you want pages with simple, fixed interactions and most of the work carried out server-side, JSP might suit your needs better. As with all these decisions, it's true that you could do this in many different technologies, it's just a matter of which best suits the task you're trying to accomplish. It's not really a matter of whether Angular is better, it's just more appropriate for some applications.

Solution 2

If you are making a single page web application then the benefits of using a front end web framework like angular or backbone are clear. They handle client side routing, templating, data binding, dependency injection ajax interaction with the back end, etc.. etc. Vanilla jsp has no facilities for building SPAs at all.

Angular really wants to talk to the backend using something like a RESTFUL api. To make your life easier, I suggest augmenting your servlet application with JAX-RS implementation like jersey or restEasy. These will give you a more natural and idiomatic way to communicate with angular.

It's still going to be a bit more work that using node (but hey you're used to that, you're using java). But you'll find it more productive than using naked servlets.

Share:
15,495

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I wonder why people are using angularjs to check things like existing username or form registration when it can be done simply by a presentation layer called jsp in combination with servlet as backend code.

    For example, angular makes ajax calls to java servlet where servlet fetches username from DB and shown back to jsp view. All this can be achieved with jsp and servlet instead of adding one more layer of angular using separate custom directives and so on which adds to more code.

    I am trying to figure out advantages of angular over jsp view layer. Things like form registration can be done with jsp instead of angular.

    Today, I spent almost 8 hours writing a program to check existing username using angular and java servlet being a back end. I am not sure if its a bug in angular or jsp where request.getParameter("Username") returns null in servlet. The parameter is passed from angular from using $http post ajax call.

    Finally I had to use some inputstream to read the value passed from angular form and return a response. Who can imagine this sort of issue?

    Finally, my question is what makes angular better than jsp. Is there any other back end sever better to be used with angular (may be nodejs?) than tomcat usually used along with java?

  • Admin
    Admin almost 9 years
    My web app will be having user registration, sending emails, feedback submission, sending sms, Customers can log in to web app and check their bills every month, analyze them with graphical views (Customisable) etc. Do you think its better with angularjs for my requirements?
  • Admin
    Admin almost 9 years
    I think you are right. I should probably switch on to REST. So far I had basic idea on soap/jax-ws webservices and I am still learning it.
  • hugh
    hugh almost 9 years
    I think the big difference will be in the user interaction style. JSP will work well for simple pages which perform single actions, like forms. If you want rich pages with lots of user interaction, Angular is likely to be a better fit. Doing analysis and graphics would make me lean towards Angular - it's very good at handling complex data models and interactions, and makes pages wonderfully extensible.
  • Admin
    Admin almost 9 years
    One confusion I always had is why angular js is called Single page application? when a normal enterprise usually has lot of pages (such as jsp pages). So using angular js means there should be only one page or it is not suitable for multiple pages?
  • Robert Moskal
    Robert Moskal almost 9 years
    Read up on it, but it generally means that there are few or no hard refreshes in the app (full round trips to the server). You use ajax to communicate with the server and look like separate pages are all generated client side. Often the whole application is hosted in a single jsp page. In practice it might be 2 or 3 jsp pages for an application instead of many dozens.