Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting null when using request.getParameter()

 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic