views:

62

answers:

3

Hi, I'm using Java+struts2+JSP as the web application framework.
I have to pass some huge objects through struts actions to my jsp pages. this makes the pages so heavy to load and on the other hand they suck the server's bandwidth out.
Is there any way to send compressed objects via struts2 to a jsp page and decompress them there?

A: 

If you need to move data inside your server side, check this:

http://www.google.de/search?q=java+gzip&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a

If you want to improve download speed for clients, enable gzip compression in your webserver.

BarsMonster
thanks for the tip, as I got it in this method the whole response is being compressed which seems more practical. I'll look into it.
SJ.Jafari
I just enabled the compression on tomcat, it made my main responses 10 times smaller.
SJ.Jafari
A: 

Sounds like you need to unzip files with JavaScript. This Answer actually provides a link to just such JavaScript. I don't know how practical the idea is though.

Vincent Ramdhanie
thanks, I might use "deflate/inflate" method to compress the objects. this js seems to be useful.
SJ.Jafari
+1  A: 

The question is a bit vague on how the objects are passed from the action classes to the JSP pages, but it appears to me that instead of forwarding the request during the execution of the request, the application is issuing a client-side re-direct to a new page.

In the JSP/servlet model, forwards are internal to the server, and do not result in a new request by the client. On the other hand, redirects will result in the browser being forced to go the new page as indicated by the server.

If possible, you should investigate the use of forwards which is the default mechanism in Struts to display the view. This will only reduce the server's bandwidth requirements.

On the topic of the large memory consumption in JSP pages, you might want to profile the application to deduce whether the 'huge' load time of JSPs is due these objects or whether it is due to the additional client request as explained above. Without such a profile report indicating CPU and memory usage, it is presumptuous to claim that object bloat is responsible for high page load times.

Vineet Reynolds
well here is the scenario: I've got a Collection<Object> attribute in my struts action class, I call this action class via an ajax call from my jsp page. in the result of ajax call, I iterate this collection into a grid.I've checked the network traffic with firebug, every part of the page is being loaded well but this object which makes page freeze for a little while!I googled around a little bit, there are some topics on zipping requests and responses on JSP/Servlet model but this seems to be different on JSP/Struts.Any Ideas?
SJ.Jafari