unable to access objects of MultipartParser class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samita
    New Member
    • Jul 2007
    • 7

    unable to access objects of MultipartParser class

    for image upload in jsp using file upload control into a blob field, i have downloaded com.oreilly.ser vlet.MultipartR equest jar file and included in my projects lib folder.But in a servlet while writing the following line
    MultipartParser mp = new MultipartParser (request, 10*1024*1024);,
    it does not work indicating that " the element neither has attached source nor attched JavaDoc and hence no information could be found".
    Can u provide me the solution to this problem. Samita
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Samita
    for image upload in jsp using file upload control into a blob field, i have downloaded com.oreilly.ser vlet.MultipartR equest jar file and included in my projects lib folder.But in a servlet while writing the following line
    MultipartParser mp = new MultipartParser (request, 10*1024*1024);,
    it does not work indicating that " the element neither has attached source nor attched JavaDoc and hence no information could be found".
    Can u provide me the solution to this problem. Samita
    When is this error shown? Do you need the sources for those classes as well?

    Comment

    • Samita
      New Member
      • Jul 2007
      • 7

      #3
      Originally posted by r035198x
      When is this error shown? Do you need the sources for those classes as well?
      Now the following code works and i m getting the filename, filepath and its size,
      but is this the corrcet code to insert the image in binary format into blob field of database or does it refer to FSO?bcoz in this code i m nowhere finding query to insert into table to blob field.
      Can u please clarify this?

      [CODE=java] package com.cognizant.s earch.upload;
      import java.io.File;
      import com.oreilly.ser vlet.multipart. *;

      import javax.servlet.h ttp.HttpServlet Request;
      import javax.servlet.h ttp.HttpServlet Response;
      import javax.servlet.h ttp.HttpServlet ;
      import javax.servlet.R equestDispatche r;
      import javax.servlet.S ervletException ;
      import java.io.IOExcep tion;


      public class UploadServlet extends HttpServlet
      {
      public void doPost(HttpServ letRequest request,HttpSer vletResponse response) throws ServletExceptio n,IOException
      {
      //upload the files
      try
      {
      String fileName = "";

      MultipartParser mp = new MultipartParser (request, 10*1024*1024);
      System.out.prin tln("After Multiparser");
      Part part;
      while ((part = mp.readNextPart ()) != null)
      {
      String name = part.getName();
      if (part.isParam() )
      {
      // it's a parameter part
      ParamPart paramPart = (ParamPart) part;
      String value = paramPart.getSt ringValue();
      map.put(name,va lue);
      System.out.prin tln("param: name=" + name + "; value=" + value);
      }
      else if (part.isFile())
      {
      // it's a file part
      FilePart filePart = (FilePart) part;
      fileName = filePart.getFil eName();
      if (fileName != null)
      {
      // the part actually contained a file
      long size = filePart.writeT o(new File("c:\\downl oads"));
      System.out.prin tln("file: name=" + name + "; fileName=" + fileName +
      ", filePath=" + filePart.getFil ePath() +
      ", contentType=" + filePart.getCon tentType() +
      ", size=" + size);
      map.put(name,fi leName);
      }
      else
      {
      // the field did not contain a file
      System.out.prin tln("file: name=" + name + "; EMPTY");
      }
      }
      }

      }
      catch(Exception ee)
      {
      System.out.prin tln("Exception in uploading the File, " + ee);
      }
      }

      }[/CODE]
      Last edited by r035198x; Feb 18 '08, 09:22 AM. Reason: Added code tags. Please don't forget them next time

      Comment

      Working...