Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem using oreilly,multipart-request with Websphere 5.1  RSS feed

 
DC DC
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using WSAD 5.1 and I am using the oreilly.MultipartRequest to upload images from my HTML page to the servlet. However, the files do not get uploaded. If I try to do a request.getParameter() on any other form attribute it returns a null. I read that this has been a bug in the versions previous to Websphere 5.0.1.
Can anyone tell me if there is a work around for this problem.
Thanks in advance for your help!!!
-DC.

My HTML looks like this:
<form method=post action="UploadImageRequestHandler" ENCTYPE="multipart/form-data" name=form1 onSubmit="window.close();">
<input type=file name=filesent onChange="DoPreview()">
</form>

the servlet does something like this:

public void doPost(HttpServletRequest oRequest, HttpServletResponse oResponse) throws ServletException, IOException {
MultipartRequest mp = new MultipartRequest(oRequest, "C:\\data\\");
}
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U have to check if the object is an instance of multi part request and take appropriate action.....else request.getparameter will always return null
 
DC DC
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried checking whether the object was an instance of Multipart Request:

MultipartRequest mp = new MultipartRequest(oRequest, "C:\\data\\");
if(mp.getClass().equals("MultipartRequest")) {
String height = mp.getParameter("Height");
System.out.println("It probably uploaded the file" + height);
}

But it seems to freeze there forever without doing anything.
I am not sure I did the right thing. I am unable to load any files into the directory. Please let me know if there is anything else I can try.
Thanks in advance for your help!
DC.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There surely must be better alternatives than that library, too. I read it to figure out how to do multipart in my own server. It's not very pretty code. Maybe it was a good design in C once, translated to Java.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
There surely must be better alternatives than that library, too. I read it to figure out how to do multipart in my own server. It's not very pretty code. Maybe it was a good design in C once, translated to Java.


I've used both but prefer this one.
http://jakarta.apache.org/commons/fileupload
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!