Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Reactjs and servlets?  RSS feed

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I took a tutorial in React. It seems it runs in it's only little world outside of an application server and the only way it can get data is with AJAX-REST calls. I am looking to re skin and application with a new front end, but keep the JEE backend intact. Management in my company is pushing React, so how can I make this work? When a user logs in, there is a lot of data structures loaded into the session and it would be impractical to load all of that in a browser.
 
Sheriff
Posts: 21503
96
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The important thing is to get the necessary data from the session into the browser, as JavaScript content. I think you have two choices:
1) Create one or more REST calls to retrieve that information. You don't need to use something like JAX-RS or Spring MVC, you can also create the calls with servlets (although it may be a bit more work).
2) Have your JSPs (or servlets, but JSPs should preferably be used for the rendering) output a script block with the necessary content.
 
Author and ninkuma
Marshal
Posts: 66823
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Skin your backend with a REST API and then use React on the front-end. Any other path will be a tar pit of misery and pain.

Edit: You could also go with the increasingly popular GraphQL backend, but that's likely more work.
 
M Burke
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I see online that React and Java don't play well together. Some people are trying to use Spring boot but it's painful. I find React frustrating, it's so different from anything else I have experience with. The learning curve is huge.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66823
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing here, but but perhaps part of the problem is learning ES6+ in addition to React? React itself can be pretty simple to get started with; but learning its toolchain (Babel and Webpack et al) is a huge hurdle, and learning all the new notation in ES6+ can make it grueling.

Also, once you throw Redux into the picture, well, now it's getting complicated...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66823
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also if it's your first client-side framework foray after JSP and servlets, it is whole 'nuther way of thinking
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!