Skip to content
  • There are no suggestions because the search field is empty.

How do I integrate Prerender with Java?

Make your Java-based single-page application fully readable by AI crawlers and search engines using the community-maintained prerender-java library.

TL;DR

The prerender-java library connects Prerender to Java applications running frameworks like Angular, Backbone, or Ember.js. Add the library to your project, configure it with your Prerender token, and AI crawlers and search engines will receive fully rendered HTML instead of a JavaScript shell. This is a community-maintained integration — installation details are in the GitHub README.


⚠️ prerender-java is community-maintained and is not officially supported by Prerender. For issues with the library itself, refer to the GitHub repository.


Step 1: Create a Prerender account and copy your token

Go to prerender.io and create an account if you don't have one. Once logged in, open your Prerender dashboard and copy your Prerender token — you'll need it in Step 3.

ℹ️ Not sure which integration is right for your stack? Ask Nexus, your AI integration assistant, inside your Prerender dashboard — describe your setup and it will recommend the right path and walk you through configuration.


Step 2: Open the prerender-java repository on GitHub

Go to the prerender-java repository and read the README. It contains the Maven and Gradle dependency declarations and the servlet filter configuration for your project.


Step 3: Add the dependency and configure your Prerender token

Follow the installation instructions in the GitHub README to add prerender-java to your project and register the servlet filter.

When configuring the filter, set the prerenderToken value to the token you copied in Step 1. This tells Prerender which account to associate cached renders with.

ℹ️ The servlet filter intercepts requests from AI crawlers and search engines and routes them to Prerender. Your website visitors bypass this flow entirely—their experience is unaffected.


Step 4: Review URL format and server thread requirements

Before deploying, check two things:

URL format: If your application URLs contain #, update them to #! instead. This follows Google's AJAX crawling protocol and ensures crawlers can identify your dynamic pages correctly.

Server threads: Run your Java application with more than one web server thread or process. Prerender makes a request back to your server during rendering—a single-threaded setup will cause it to hang.


Step 5: Deploy and verify your integration

Deploy your application. Then confirm Prerender is intercepting crawler requests correctly by running the following curl command, replacing the URL with one of your own pages:

curl -v -A googlebot https://www.yourpage.com/

Look for Prerender-specific response headers. If they appear, your integration is active.

✅ Your integration is working when the curl response contains Prerender headers and returns fully rendered HTML—not a JavaScript shell. Cached pages should appear in your Prerender dashboard within 2–5 minutes of the first crawler request.

If you don't see Prerender headers, check your servlet filter configuration against the README and confirm your Prerender token is set correctly. For the "Prerender Integration Not Detected" error specifically, see What should I do if I receive a "Prerender Integration Not Detected" error?.


💬 Still need help?
If you have questions about configuring or troubleshooting the prerender-java integration, our support team can help.
→ Contact us at support@prerender.io


Related articles

Was this article helpful?