Meaningless Drivel is fun!*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting null when using request.getParameter()" Watch "getting null when using request.getParameter()" New topic
Author

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
sunil
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
author
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,
boundry=---4j546i56hi5i76in549ri-------------------------
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.
Sean
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: getting null when using request.getParameter()
 
Similar Threads
Delete button and scriptlet
problem with multipart/form-data
File uploading and data collection problem
File Upload help
Not able to access hidden fields in servlet