3

Edit: This question was asked in response to incorrect observations I made. Please disregard.

I know that JSPFs are used to define fragments that can be included inside JSPs.

Beyond this convention, are there differences in how the server (eg Tomcat) or the user-agent (eg firefox, google bot, etc) might treat a file?

Our website has a few popups / dialog boxes that are loaded via AJAX. The content for most of these are stored inside JSPFs, and referenced in the url (eg, http://www.domain.com/folder/file.jspf). Recently we found that if the popup was inside a JSP instead, it would behave differently in the following ways:

1) Google would index it as a standalone page.
2) jQuery's $(document).ready(function() {alert('this code is executed')}); never runs.

WoodenKitty
  • 6,521
  • 8
  • 53
  • 73

2 Answers2

2

First of all, the browser handles neither JSP nor JSPF files directly.

Instead, the browser requests a resource by URL and the server (in your case, Tomcat) responds with a document in HTML format.

Yes, you asked for a .jsp resource, but the server compiled the page and Tomcat produced HTML output to the browser.

At that moment, the browser handled a plain HTML page.

I do see a potential problem with directly-accessing a JSPF file via a URL. Fragments should be included by a special JSP directive: include. See Use of Composite View Patterns in Code conventions

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77
Alex Karasev
  • 1,108
  • 2
  • 13
  • 24
  • Hello. Thank you for your response, but I don't think it addresses my question. I know the JSP is converted into HTML by the server, and I know that JSPFs aren't conventionally linked directly. That doesn't explain why there was a different result for the browser and for Google. – WoodenKitty Sep 22 '15 at 04:36
2

The only way to allow to construct a URL to arrive to a jspf file is putting them in the same directory as normal JSP files. (This is not allowed if you put them inside /WEB-INF/) So, when you do that, will depend on the container you are using. Tomcat will retrieve the page as a text document. A front-end web-server, however, can block these URLS. What is .jspf file extension? How to compile it?

Hope it helps.

Community
  • 1
  • 1
Fabri Pautasso
  • 485
  • 6
  • 17