tags:

views:

45

answers:

2

To give you the situation in abstract:

I have an ajax client that often needs to retrieve 3-10 static documents from the server. Those 3-10 documents are selected by the client out of about 100 documents in total. I have no way of knowing in advance which 3-10 documents the client will require.

Additionally, those 100 documents are generated from database content, and so change over time.

It seems messy to me to have to make 10 ajax requests for 10 separate documents.

My first thought was to write a jsp that could use the include action. ie in pseudo code

for (param in params){
    jsp:include page="[param]"
}  

But it turns out the tomcat doesn't just include the html resource, it recompiles it, generating a class file every time, which also seems wasteful.

Does any one know of a neat solution for combining apache requests to static files to make one request, rather than several, but without the overhead of, for example, tomcat generating extra class files for each static file and regenerating them each time the static file changes?

Thanks! Hopefully my question is clear - it's a bit long-winded.

A: 

Anyone have any thoughts on this?

Jeremy
A: 

You can certainly write a Servlet (or JSP if you're really insistent on doing so) which will serve the contents of a set of documents.

However, doing so would encounter some of the following issues

  • How do you delimit the documents so that the clients know which is which
  • How to stop the clients from requesting something they don't have permission to (this one is tricky)
MarkR