0

If any one has an idea

how can i access a file in servlet that are upload in jsp for example

my jsp file is

upload.jsp

<body action="Check" method="get">
<form name="f1">
<input type="file">
<input type="submit" value="Click Me">
</form>
</body>

Check.java

Now i need that file in my Check.java file so how can i access that file in my servlet file (Check.java)

Please any one has an idea please suggess me.

user3222568
  • 13
  • 1
  • 7

3 Answers3

0

There should be a parameter with the form name getParameter("f1")

onesixtyfourth
  • 744
  • 9
  • 30
0

Check this to process uploaded file in Servlet.

http://www.tutorialspoint.com/servlets/servlets-file-uploading.htm

Sunil Singh Bora
  • 771
  • 9
  • 24
0

Check this uploaded file in Servlet as:

<form method="post" action="check" enctype="multipart/form-data">
                <table>
                     <tr>
                        <td> Photo: </td>
                        <td><input type="file" name="photo" size="50"/></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <input type="submit" value="Save">
                        </td>
                    </tr>
                </table>

update:

    // Get part using HttpServletRequest’s getPart() method

    Part filePart = request.getPart("photo");

    // Extract image name from content-disposition header of part

   String imageName = getFileName(filePart);

    System.out.println("***** imageName: " + imageName);

click:1

click:2

jmail
  • 5,944
  • 3
  • 21
  • 35