I am using Glassfish Server.I have seen the apache file upload to solve it...but i want to implement it in glassfish server.
image.html
<form action="" method="post" enctype="multipart/form-data">
    Select a file:
    <input type="file" name="first" id="first" />
    <br />
    <input type="button" name="button" value="upload" id="button" />
    <p id="test"></p>
   <img src='Unknown.png'  id="profile_img" height="200px" width="150px" />
</form>
test.js
$(document).ready(function() {
    var filepath= $("#first");
    $('#button').click(function() {
        $.ajax({
            type:       "post",
            url:        "imageservlet",
            data:       "user="+filepath.val(),
            success:    function(msg) {
                            $("#profile_img").attr('src',msg);
                            $("#test").html(msg).fadeIn("fast");
                        }
        });
    });
});
imageservlet.java
String user=request.getParameter("user");
out.print(user);
the output is file name not full path.
 
     
    