Results 1 to 5 of 5
  1. #1
    itssiva is offline Member
    Join Date
    Sep 2008
    Posts
    1
    Rep Power
    0

    Default uploading a file

    Hi All

    Can any one please help me in uploading a file from client to server. I have used cos.jar and commons upload file jar. They are working when we have to set the attribute enctype="multipart/form-data" of <form> tag.

    But the problem is our framework will generate the <form> tag based on the html template. so it is setting the enctype="application/x-www-form-urlencoded". Is it possible to send a file to server using enctype="application/x-www-form-urlencoded". If it is, can you post the code.

    thanks in advance
    siva

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    There are ways of doing this. URL.decode() or something
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    angelicsign is offline Member
    Join Date
    Dec 2008
    Posts
    25
    Rep Power
    0

    Default

    how about if the uploading (byte array) is sent from j2me to server, what is the syntax to retrieve the sent code?

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Arrow Servlet Request

    javax.servlet.ServletRequest has several methods of getting files, we have to first determine the general nature of the file and what the operational arena can accept as a file.

    There are two interfaces of consequence, javax.servlet.ServletRequest and javax.servlet.http.HttpServletRequest, both of which must be examined for candidate method calls. Java does not have a good and complete "upload file" coded and working, we have to dig rather deep for that and it is better if we can find one of the library methods to do the job. Best is to use getParameter(java.lang.String) which would then be sent to the server from a simple html form:
    Java Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <!-- Created on Dec 16, 2008 6:38:56 AM -->
    <html>
       <head>
          <title>
             short video totally send to the server
          </title>
          <meta name="GENERATOR" content="Arachnophilia 5.1">
          <meta name="FORMATTER" content="Arachnophilia 5.1">
       </head>
       <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
          <form action="http://yourSerlvet?val=someValue" method="post">
             <input type="text" name="struggle with project" size="40" maxlength="80" value="Senior,I need your help about uploading file from j2me ">
          </form>
       </body>
    </html>
    but that will not send binary data - to get the video type of bytes, I would try getInputStream() of ServletRequest - which brings a SerlvetInputStream ..... which is an abstract class ..... which brings us to a central design issue: What is it you are trying to achieve? If you are doing student work and chose to upload a video as a first project we must redirect your efforts and upload a simple text someting or other to start off with.

    For some reason, we seem to have too many people in the world who will use IPV4 spoofing to intrude on legitimate proprietary interests of commercial works. It just does not work, the situation is deeply involved in real-world issues that are not appropriate to five years out of college; some people never grasp the matter and others make a game of it. I have an eighteen hundred page book from Addison-Wesley Professional on the matter and I have to keep it hidden away as it is just too difficult to work the matter.

    Try this code I posted earlier in the thread, that can be made into a JSP directly with beginner level skills, and would call a servlet. To make a servlet, you just subclass HttpServletRequest and start writing. It will be awhile before you get all of this working.

    What books are you reading, what books have you read, how many lines of code have you written, what editor are you using and be sure to welcome Norm back.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  5. #5
    peppem is offline Member
    Join Date
    Jan 2009
    Location
    italy
    Posts
    16
    Rep Power
    0

    Default

    Look at apache library for upload using servlet

    h t t p://commons.apache.org/fileupload/
    Last edited by peppem; 01-16-2009 at 12:19 PM.
    Article and examples about Java EE world
    http://programmaremobile.blogspot.com

Similar Threads

  1. Uploading a file with Servlet
    By farakhkhan@yahoo.com in forum New To Java
    Replies: 0
    Last Post: 03-10-2008, 09:02 PM
  2. File Uploading
    By aaliadhurue in forum Advanced Java
    Replies: 4
    Last Post: 01-16-2008, 07:56 PM
  3. uploading files
    By javaplus in forum Java Applets
    Replies: 1
    Last Post: 01-13-2008, 11:14 PM
  4. Uploading image using JSP
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-11-2008, 10:16 AM
  5. uploading sound file in java
    By po0oker in forum Advanced Java
    Replies: 8
    Last Post: 11-04-2007, 12:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •