This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Production-Ready Serverless (Operational Best Practices) and have Yan Cui on-line!
See this thread for details.
Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization forum!
  • 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
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Reactjs and servlets?  RSS feed

 
Ranch Hand
Posts: 421
  • 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: 21687
101
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.
 
Marshal
Posts: 67254
170
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: 421
  • 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
Marshal
Posts: 67254
170
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
Marshal
Posts: 67254
170
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
 
You showed up just in time for the waffles! And this tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!