Here is what I am trying to do:
Upload a file from a form with POST method and get the progress status with GET method. And I put a progresslistener variable in the session to feedback the upload progress to the AJAX in the frontend. For some reason, in the doGet and doPost methods in the servlet, the session.toString() returns different IDs. Shouldn't they be the same if the requests are from the same browser?
Ignore the results of toString(), it's not specified what that format may be. I don't know what you mean by ID, but that could be the hexadecimal hash code of the actual object. You should use getId() instead, which returns the actual session ID. That should be the same.
I changed to session.getId() and it's the same. I still got 2 different IDs.
Then I moved the code from doGet() to doPost() and there is a ServletFileUpload.isMultipartContent(request) to judge if the request is file uploading or getting progress. Still, I got 2 different IDs.
Note that most of the time, I got sames IDs. Just occasionally, 2 different IDs occurred.
Can somebody help please?
And you are getting different sessions? Your focus on the session ID kind of led us away from the actual question, which I guess was why were you getting different sessions. Perhaps your AJAX code is not handling cookies correctly.
Joined: Oct 25, 2011
Here are some details about my issue. If the request is a file uploading, get/create a session. If the request is for a progress update, get the session. The problem is sometimes it can never get the session which has been created in the 'file uploading' code. I can't figure out why.
Here is the code: