jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes session lost in MultipartRequest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session lost in MultipartRequest" Watch "session lost in MultipartRequest" New topic
Author

session lost in MultipartRequest

Conie Ooi
Ranch Hand

Joined: Jun 09, 2002
Posts: 31
Hi, I'm adding in file uploading features to my application. I'm having a problem that whenever I use enctype ="multipart/form-data" in my jsp page, the session will become null. It works fine when I remove the above enctype, but the file uploading no longer function.
Do you have any idea how to over come this problem?
Any suggestion will be highly appreciated. Thanks a lot.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You're right, it would too. I've never had to support Multipart and Sessions at the same time so I'd never noticed...
You'll probably have to use request.encodeURL() to pass the session and you might have to turn on URL rewriting in the properties of your server (eg if you're using Websphere)
Dave
Mario Rendon
Greenhorn

Joined: Jul 11, 2002
Posts: 24
Extension to David ..
if you use request.encodeURL()
in a client that has cookies enabled.
the encodeURL() won't work ..
the pedestrian solution would be to encode your own URL
using request.getSession().getID()
and use it to encode the URL manually..

your URL would be as follows
ORIGINAL_URL+ ";jsessionid="+ request.getSession().getId();
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Guys, does this always happen? loosing a session when using enctype ="multipart/form-data" ??
i'm using forte for java and it doesn't seem to happen this.. my application requires the user to log in to upload a file.
i'll have to check that then...


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
 
Don't get me started about those stupid light bulbs.
 
subject: session lost in MultipartRequest
 
Similar Threads
getting session variable from multi part request
Redirect back to portlet from servlet keeping same parameters
Problem in Uploading Files
Problem While Uploading
Struts - Problem in Uploading enctype=�multipart/form-data�