• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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: 21555
100
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: 67193
169
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
Marshal
Posts: 67193
169
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: 67193
169
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
 
Do you want ants? Because that's how you get ants. And a tiny ads:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!