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
JavaRanch » Java Forums » Java » Servlets
Bookmark "session lost in MultipartRequest" Watch "session lost in MultipartRequest" New topic

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

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)
Mario Rendon

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
I agree. Here's the link:
subject: session lost in MultipartRequest
It's not a secret anymore!