views:

215

answers:

4

I am creating a Web Application using JSP, Struts, EJB and Servlets. The Application is a combined CRM and Accounting Package so the Database size is very huge. So, in order to make Execution faster, I want prevent round trips to the Database.
For that purpose, what I want to do is create some temporary XML files on the client Machine and use them whenever required. How can I do this, as Javascript do not permits me to do so. Is there any way of doing this? Or, is there any other solution which I can adopt in order to make my application Faster?

+2  A: 

You should be caching on the web server.

As you've no doubt realised by now, there is a very limited set of things you can do on the client machine from a web app (eg, write cookie).

Jamiec
+2  A: 

You do not have unfettered access to the client file system to create a temporary file on the client. The browser sandbox prevents this for very good reasons.

What you can do, perhaps, is make some creative use of caching in the browser. jQuery's data method is an example of this. TIBCO General Interface makes extensive use of a browser cache for XML data. Their code is open source and you could take a look to see how they've implemented their browser cache.

If the database is large and you are attempting to store large files, the browser is likely not going to be a great place for that data. If, however, the information you want to store is fairly small, using an in-browser cache may accomplish what you'd like.

justkt
A: 

You can make your application use the browser plugin Google Gears, that allows you a real clientside storage.

Apart from that, remember, there is a huge overhead for every single request, if needed you can easily stack a few 100 kB in one response, but far away users might only be able to execute a few requests per second. Try to keep the number of requests down, even if it means adding overhead in form of more data.

@justkt Actually, there is no good reason to not allow a web application to store data. Indeed HTML5 specifications include a database similar to the one offered by Google Gears, browser support is just a bit too sporadic for relying on that feature.

eBusiness
@ebusiness - storing data is one thing. Access to the file system is a whole different ballgame. I will edit my answer to clarify. I certainly wouldn't want to allow any browser-based application access to my file system - read or write - without my explicit permission, which I can choose to give liberally or sparingly. You'll notice Gears doesn't work without user permissions, for example.
justkt
A: 

If you absolutely want to cache it on the client, you can create the file on your server and make your web app retrieve it. This way the browser will fetch it and keep it on the client cache.

But keep in mind that this could be a pain for the client if the file is large enough.

Frank