Can we use angular2 universal with server side JAVA - java

I have an web project which is using angular 2 on front end and java spring 4 on server side. I am somewhat new to angular 2. I wanted to use angular universal for prerendering. How can i able to achieve it?
is there any tutorial which explains it with Java on server side?
Is there any other library that will help me out?

Fortunately their's a library (Angularj-Universal) or a solution for rendering Angular4 applications on the server side (Spring Boot or Java EE) and sending them to the browser as 'already-bootstraped' application.
Angularj-Universal library is a server side rendering for Spring Boot and Angular4 based on the J2V8 library, also you can implement your own render implementation.
On the home page of this project you will find a useful guides step-by-step on how to create angular application from scratch and integrate it with Spring Boot using #angular/cli

Angular 2 Universal works with nodejs/asp.net only.
You could use java server for rest api and separate nodejs server for pre-rendering or play with v8 jni bindings.
https://github.com/angular/universal#getting-started

Unfortunately there are not much support available for now.
Angular Universal was originally built to work with a node.js back-end. There are adapters for most popular node.js server-side frameworks such as Express or Hapi.js. In addition to node.js, however, Angular Universal has ASP.NET Core support. In the near future we hope to add support for Java, PHP and Python.
-Related page-
You can follow this issues (spring boot support & java backend) on github.
Additionally, check out this libraries;
J2V8 A Highly Efficient JS Runtime For Java
Java's Nashorn Javascript engine (link1)

Not sure if you are looking for this but here is something that might help you
Since you want to deploy your angular app within spring-boot app follow these steps
Create a public folder under resources in your spring-boot project
ng-build --prod, type this command on you angular project which will create a dist folder under your angular project directory
copy files from you dist folder and place it in public folder under resources of your spring-boot project.
This will help you run your angular-app under spring-boot.

Related

Start Spring maven project with Angular 2+

I am learning stuff which I wrote in title. I need som good point where to start. Old I found is old sheets for it, so I decide ask to help here. Can you tell me how to start project with these technologies? Do exist some artifact for Spring 5 and Angular least in version 4? Pure spring project I should generate from start.spring.io but it's for spring boot, and I read boot is not good for beginners, and still without angular. Can you give me some hints? Thanks.
I will be also glad for some git repository with these technologies for inspiration.
You must to notice to the these notes:
If you want to use AngularJs you can add your angular javascripts to the every html files and use it.
]f you want to use Angular 2+, it is difference than AngularJs because Angular 2+ is written with Typescript and then Transpile to javascript, Angular 2+ has one html file(index.html) and your javascripts after transpile add to this file.
If you want to use both of Spring and Angular 2+, you can use Angular project instead of Client Project and Spring Project instead of Backend Project, and how to these projects communicate each other it's very easy By Spring API.
And the Bad Project is mixing Spring and Angular Project, in these situation you must to try hard to join Angular and Spring.

Angular 2 Basics - Integration with Spring Boot - Can Angular 2 instance run within a server

I am new to angular 2 and js frameworks so this question is probably going to sound a bit stupid, I have a task at work where I am looking to integrate angular 2 with Spring boot application, I went through couple of tutorials online and found that you can configure the proxy setting for paths inside angular to redirect calls to spring boot application for various paths.
For reference: https://dzone.com/articles/angular-2-and-spring-boot-development-environment
The question I want to ask is that since Angular is a js framework and I thought that it could be completely integrated with any application, like plain old javascript, html and css. In a way that only a single port is required to launch the server and jsp based models can be served through it.
But with Angular2 you need a separate port of its own to do anything. Is that true?
If it is then why it is like that?
If not then can you please direct me to a guide which describes how to integrate it in a way that it would be served through the server?
But with Angular2 you need a separate port of its own to do anything. Is that true?
No, not at all. An Angular application, once built, is just a set of satic files that can be served by any web server, including the one running your spring boot app. Those file aren't "run" on the server. They're just downloaded by the browser.
During development, though, it's much more productive to have a separate web server like the one that Angular CLI starts up, and which watches your source files, rebuilds your application on the fly, and serves it immediately. Since this server can also serve as a proxy to your spring server, you can just pretend your spring server hosts the angular files.
An alternative is to use your angular build tool to build the app to some directory, and configure spring to serve static files from that directory.
In production, you'll simply build the production-ready angular app, integrate the generated files inside the spring boot jar file (inside the static folder, typically), and run the spring boot application as usual.

Possible to include Client JAVA API libraries in Web-services?

We want to develop a Java based Web-services (since the API's we want to use are Java based)
I would like to know if it's possible to use the IBM Rational Team Concert Plain Java API's (https://jazz.net/downloads/rational-team-concert/releases/5.0/RTC-Client-plainJavaLib-5.0.zip) as part of the Web-servicesand deploy them in the server?
Basically we use these API's on a client based Java applications. What I am looking at is more like a services which can be consumed by many applications
Anyone has any experience in deploying the client based API in the server as Web-services?
After multiple tries, it is possible to use the RTC Plain Java API's as Webservices.
How I did:
Followed the simple Webs Service creation tutorial (http://wiki.eclipse.org/Creating_a_Bottom-Up_Java_Web_Service)
Adapted to my needs
First added the "RTC plain Java API's (JAR's)" to the Eclipse build path
Then added the "RTC plain Java API's (JAR's)" to the "WebContent/Lib/" folder of my Dynamic web project
Created a new Web service & Web service client
I was able to login to RTC via this for starters

Embedable Java-based HTTP server with (PHP) scripting support

For my Java project I need to embed a web server to provide various web pages to the user. Until now we used the "official" com.sun.net.httpserver.HttpServer class, which basically works fine.
However, now we want to extend our application in order to not only serve static HTML pages via the embeded HTTP server, but also dynamic content (PHP if possible).
Any recommendations?
EDIT: Nevermind, I found it quite easy to integrate Jython within my Java application :)

Using AWS Elastic Beanstalk with a Java/BlazeDS/Spring application

Is it possible to deploy my Spring/BlazeDS/Java application to elastic beanstalk? I'm using MyEclipse and built a Java Web Project with the required jar files etc. Do you need to specifically create an AWS Java Web Project - reason I ask is the options to include the BlazeDS files aren't there - so I'm wondering if Spring / BlazeDS is even supported? By default the turnkey blazeds runs through Port 8400 - so I imagine there are some additional tasks required to configure the endpoints to work through port 80?
Gracias!
Take a look at this example. Will be trying something similar over the next few weeks.
http://www.riaspace.com/tag/aws/
BlazeDS is not a standalone application, it consists from a bunch of jar files which should be added to your web application. You will also need to declare a servlet in the web.xml file. I wrote an article a couple of years ago how to add the blazeds jar files to a java web application (and what to configure), you can take a look here.

Categories