A secret hidden image of chair 1. Find it at your peril. A secret hidden image of chair 2. Find it at your peril. A secret hidden image of chair 3. Find it at your peril. A secret hidden image of chair 4. Find it at your peril. A secret hidden image of chair 5. Find it at your peril.

Serving XML in JSP Sitemap Files

AdCavern - Ethan's advertising, marketing, business, and SEO leadership blog.

Last updated 10/25/21 ✧ First posted 12/29/14
~3 minutes to read.

A client of mine, which I will anonymize by telling you that they’re a capybara life insurance company, uses a CMS that makes it impossible to generate an automated XML sitemap file. Or any XML sitemap file. Or any XML files at all…

can i use jsp with xml sitemaps for seo?

Important Update: This post was originally published in 2014 and references the old Search Console (Google Webmaster Tools). I have not tested JSP sitemaps in the new Search Console. If you have, I’d love to hear about it.

After a large restructuring of the site, getting an XML sitemap to submit to Google Search Console became a priority for us. But the capybaras still couldn’t get around their CMS limitations.

We even manually created an XML sitemap file to upload, but the CMS locked it out of the root folder like a malevolent artificial intelligence.

While my next step was going to be creating a TXT sitemap, which is just a simple list of one URL per line, the capybaras had a different idea.

Their CMS allowed them free reign to create JSP (JavaServer Page) files. “We’ll just create the sitemap file in that!” they squeaked (as capybaras are prone to do).

That’s Not Gonna Work

JSP files are used to serve up various other types of pages. I usually see it for HTML, and in fact even made an ill-fated JSP-based portfolio back in my early dev days.

I knew that it could be used to serve other filetypes, including XML. But that didn’t make it an XML file itself.

Going to the capybara’s website /sitemap.xml was of course a 404 error page, and obviously the file could only be reached at /sitemap.jsp.

view of the jsp sitemap file

Viewing the source, it did indeed show up as a coded XML file, but again – still JSP in actual format:

jsp sitemap's view source

Just in case, I checked with Google’s help file. Yup, the normal options here, nothing new:

google's help file on xml sitemaps and other formats

I also checked with the Sitemaps.org official protocol. Same story again:

sitemaps.org official rules for xml sitemaps and txt etc

So I said, “Go ahead and try, capybaras, but it’s probably not going to work.”

They tried.

It Didn’t Work

We submitted the file to Search Console on October 20th, and Search Console spat it back out, saying, “what the heck, this isn’t XML!”

search console webmaster tools rejecting the jsp sitemap at first

It seemed like the story was over. But then…

It Worked

Over two weeks later, with no further action on our part or anyone else’s, Google Search Console decided it wanted to accept it after all.

search console spontaneously accepting the jsp sitemap file

A quick test of it even confirms the “no errors found” message:

no errors in the jsp xml sitemap

So it appears that serving an XML sitemap over a JSP file does indeed work, although it may take a few weeks to get it recognized.

Conclusion

It appears you can use JSP files for your XML sitemaps.

I can’t say I’d recommend it, since it took so long to be processed, and we haven’t yet tried to change it – I imagine that may take weeks more.

But if it’s truly your only option, it’s definitely better than nothing. It certainly worked for my capybaras.

this capybara is so happy about using jsp in xml sitemaps

My capybara clients told me they had read a source saying it worked, but failed to link us the source, and I couldn’t find one anywhere. So now I will become the source. If possible, I will try to send this page back in time for them to reference, and get into nice bootstrap paradox with my own blog.

✧ ✧ ✧
Written by Ethan J. Hulbert.

AdCavern - Ethan's advertising, marketing, business, and SEO leadership blog.

Google Knows Where You Sleep & What Your House is Made Of