Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Returning a html status code to the client browser

843836Nov 7 2003 — edited Nov 10 2003
Hi,

Can anyone help me with a problem that I am have with regard to returning a html status code of NO_CONTENT to the client browser?

The Problem:
Basically I have a html form with a SAVE button. When the user clicks the SAVE button the data in the form is sent to the web server which then saves it in a database and the same populated form is then sent back to the client. From the users point of view they click the SAVE button and the screen is refreshed with the same data. The problem with this is that the data only needs to be SENT to be saved but not necessarily resent back to the client browser from the server i.e. from a user's point of view I don't want the screen to refresh by disappearing and then coming back again. There is a lot of data in the form so this refresh can take a considerable amount of time as the html can take a while to download.

The Potential Solution:
What I want to do is send the data to the server where it will be saved in the database and then return a html status code of NO_CONTENT to the browser (always Internet Explorer) so that the page doen't get refreshed / downloaded unnecessarily. I've implemented this and the save can now take as little as 10% of the time it used to take because the data is only sent and not received again.

The problem with the potential solution:
It works fine most of the time but not all of the time. We tested this change and it worked great but when we released it live it didn't work for some people. For most people you can see the status bar at the bottom of IE zip along as the data is sent to the server so you can see when it has finished or received the status code back. For the people it didn't work for they would get an almost full status bar at the bottom but the blue would never quite disappear to indicate that it was finished. It was as if it was sending the data from the server but not getting a response at all when it should have been getting the NO_CONTENT status code.

The Code:

I'm using Struts so the line of code I had originally used after the data had been saved to the database was:

return (mapping.findForward("timesheet"));

I changed this line of code to:

response.setStatus(response.SC_NO_CONTENT);
response.flushBuffer();
return null;

Can anyone see what the problem is here? Are the new lines of code not guaranteeing that the response is being sent back to the client? Is there a better way to simply return a status code when you don't want return a JSP page?

Any help would be greatly appreciated.

rgds,

Dave
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2003
Added on Nov 7 2003
6 comments
132 views