It's not a secret anymore!
The moose likes Servlets and the fly likes getting null when using request.getParameter() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting null when using request.getParameter()" Watch "getting null when using request.getParameter()" New topic

getting null when using request.getParameter()

sunil kumre
Ranch Hand

Joined: Dec 23, 2000
Posts: 64
i have a form(fields having input type as "TEXT" and "FILE") in my jsp.when i submit this form the action goes to an underlying jsp.The forms has the attribute ENCTYPE set to "multipart/form-data".
Because of this when i retrieve parameters in the underlying jsp using request.getParameter()...i'm getting null.
The form fields are to be stored in database and the FILE field is to be uploaded using jspsmart package.
any help???
thanks in advance
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

there are apparently a few web servers that don't like the multipart/form-data.

Specifically, iPlanet does not have a properly written webconnector, so what happens is it tries to do a regular parse on multipart/form-data, doesn't get a result it expects, and when you try to use it, it gives you nulls. This is actually a known behaviour, buried in the documentation.

Perhaps your server does something similar.
Sean MacLean
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
Actually, since multipart data is intended for sending large blocks of binary data, the browser formats the post differently. Instead of the normal name/value pairing in the request header, the data of put into delimited blocks after the header. The boundry marker ussually looks something like this,
The server isn't expected to do anything with this since handling this data is a little tricky. It would be nice if Sun added a sub class of servlet that helped to parse multipart data but until that happens, check out the orielly multipart code from the Servlet Programming book for some ideas on handling this type of data. Better yet, if you're not uploading any files, don't use multipart encryption.
I agree. Here's the link:
subject: getting null when using request.getParameter()
It's not a secret anymore!