Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating JSP with AngularJS, Is it a concern in real world? [closed]

Tags:

Am I going in a right direction of learning Angular JS?

I'm new to AngularJS but managed to run a jsp file which contain AngularJS code, and made a test calculation/addition and it worked good.

Later when I search web forums, I came to know they are both not supposed to work together as it can cause trouble.

I've used netbeans and GlassFish Server.

like image 728
user2986018 Avatar asked Mar 08 '14 04:03

user2986018


People also ask

Can we use JSP with AngularJS?

Using AngularJS directives vs JSP custom tags The answer is yes! As a matter of fact, it is easy to bind any HTML element to a Javascript object. The only difference is that now the binding occurs on the client-side instead of the server-side.

What is wrong about AngularJS?

Problems with people. Firstly, since the framework is overcomplicated, not many developers really know it well and it is hard to find such developers is very hard. Secondly, server developers won't understand what is going on front-end and won't be able to read the code at all.

Can AngularJS be used with Java?

One way is to build Angular with Java. In the development phase, we can run Angular and Java on separate ports. The interaction between these two happens with proxying all the calls to API. In the production phase, you can build the Angular app and put all the assets in the dist folder and load it with the java code.

What is angular JSP?

AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write.


1 Answers

I wouldn't mix a Servlet/JSP tech with an SPA (single page app....driven by angular in your case). What you can do is use a tool like SpringMVC (or Jersey) that has a single JSP which is your angular driven SPA. That way you have lots of control over the initial HTML/JS/CSS payload in the initial response. Once that "app" is loaded, all it's communication with the server is done via XHR calls ($http or $resource in angular). Spring makes this pretty simple to create using @Controller and giving you all the flexibility you need... things like spring security and dependency injection.

I've been working in my spare time on something simple just like this to help java server side people get into Angular.

the idea is that you'd have a controller that returns a JSP when you make a GET request to

http://your.site.com/contextRoot

That page would have the JS/CSS links to load Bootstrap/JQuery/Angular/Whatever... From there the angular router would kick in and your URL might end up like this

http://...../contextRoot#home

All communication between the JSP running angular on the client and the server is done with $http calls and you can make controllers in Spring to handle all this.

I'll post back here once I have my "Springular" app available

like image 189
Jason Avatar answered Sep 28 '22 11:09

Jason