File upload using jsp and servlet

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น • 119

  • @rachitbhatt40000
    @rachitbhatt40000 3 ปีที่แล้ว +4

    Thank you very much! You showed me how to save an image. I was been search for this for a week! You made my submission possible!

    • @TechTutorialCN
      @TechTutorialCN  3 ปีที่แล้ว +1

      I am glad that it’s helpful to you 🥰

  • @Universe-iq
    @Universe-iq 3 ปีที่แล้ว +1

    very usefull video, thankYou very much,i wish you every thing be succes!!!

  • @mobin_alizadeh
    @mobin_alizadeh 6 หลายเดือนก่อน

    Thanks a lot , very useful

  • @omkarvhanamani6312
    @omkarvhanamani6312 4 หลายเดือนก่อน

    Unchecked exceptions come sir how to fix

  • @ideolinoagostinho1612
    @ideolinoagostinho1612 ปีที่แล้ว

    Voltei para apontar onde está o erro que todo mundo está falando e o motivo das imagens não abrirem depois do upload.
    A instância: is.read(); do método uploadFile, tem que receber a variável byt… ou seja, ela deve ficar desse jeito: is.read(byt).

  • @vinayakchidrawar7852
    @vinayakchidrawar7852 9 หลายเดือนก่อน

    hey i want to get the name of user & img at same time i have already used this but my code is showing null null values why? and if not null then it is showing nothing? plz help

    • @TechTutorialCN
      @TechTutorialCN  9 หลายเดือนก่อน

      Sorry I didn’t get your point.

  • @akadeadahot7067
    @akadeadahot7067 4 ปีที่แล้ว +1

    sir i have upload the file in directory of eclipse but it showing looks like don't support format so what can i do im trying since 4 days

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      Think there is an issue with file read and write. you can share your GitHub resource. I will take a look.

    • @akadeadahot7067
      @akadeadahot7067 4 ปีที่แล้ว

      @@TechTutorialCN im unable to push the project to git hub resource here im sending the code
      String filename=part.getSubmittedFileName();

      String path=getServletContext().getRealPath("img"+File.separator+"products"+File.separator+filename);


      System.out.println(path);

      InputStream is=part.getInputStream();
      byte [] data=new byte[is.available()];
      is.read();
      FileOutputStream fos= new FileOutputStream(path);
      fos.write(data);
      fos.flush();
      fos.close();

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      Remove this line : System.out.println(path):

    • @akadeadahot7067
      @akadeadahot7067 4 ปีที่แล้ว +5

      @@TechTutorialCN not i have solved that problem just have to add
      is.read(data); // pass here bytr array name to read the input thank u

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      @@akadeadahot7067 you are welcome

  • @JunedKhan-ef8ih
    @JunedKhan-ef8ih 2 ปีที่แล้ว

    Sir I m getting issues with image
    When I m openning image in folder it is no opening and snowing this format is not supported

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว

      You can use Apache common file upload jar file.

    • @lavanyam1762
      @lavanyam1762 2 ปีที่แล้ว

      I'm also facing this problem..I can't open the stored image file.. I'm using apache common file upload jar.

  • @vadakkanchottanikara
    @vadakkanchottanikara 4 ปีที่แล้ว

    Could u help me, user part android, server part jsp.
    How to upload image

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      You mean you want to upload image in android app development using java?

    • @vadakkanchottanikara
      @vadakkanchottanikara 4 ปีที่แล้ว

      @@TechTutorialCN yes

    • @vadakkanchottanikara
      @vadakkanchottanikara 4 ปีที่แล้ว

      @@TechTutorialCN could u pls help...

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว +1

      @@vadakkanchottanikara I have no practice with android since my 3rd year in university. I think the backend process will be the same.

    • @vadakkanchottanikara
      @vadakkanchottanikara 4 ปีที่แล้ว

      No.. dear.
      Did u get time pls help

  • @atLe-gb5qd
    @atLe-gb5qd 2 ปีที่แล้ว

    Hello, thank u for the tutorial. I uploaded the xml file that have tags and contents but after that I checked the file which is empty, the file has nothing in it. Can you help me pls. Thank u

  • @deepikasrinivasasharma7481
    @deepikasrinivasasharma7481 4 ปีที่แล้ว +1

    can you add a code for an admin can upload videos/movies to the page and user can download them(only download.no stream able) . Something like a movie down-loader web page or Netflix

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว +2

      hi, dear thanks for your comment. in next video i will explain that. for that please subscribe my channel and turn notification to get the update.

    • @deepikasrinivasasharma7481
      @deepikasrinivasasharma7481 4 ปีที่แล้ว

      @@TechTutorialCN Hello sir. con you do this tutorial before 24th of April please . I really need this kind of a video before 25th for to do a project. Because of lockdown there is no one to help.

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว +2

      I will try my best. I am also working on my research paper. And extremely busy. But I will try to do that for you.❤️

    • @deepikasrinivasasharma7481
      @deepikasrinivasasharma7481 4 ปีที่แล้ว +1

      @@TechTutorialCN thankyou so much Sir

  • @zulfikharahmad2166
    @zulfikharahmad2166 2 ปีที่แล้ว

    In my ECLIPSE IDE,I am unable to find getPart method ,due to which unable to upload file as explained in this video,please suggest

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว

      Please make sure that you choose jsp version 3.0 or above on project creation time.

    • @varnithareddy4866
      @varnithareddy4866 2 ปีที่แล้ว

      @@TechTutorialCN where is that option available?

  • @pranjalchourasiyagsmca1437
    @pranjalchourasiyagsmca1437 2 ปีที่แล้ว

    it is not working the path is showing null, how can i resolve it

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว

      Please check the context path and also the folder directory

  • @guillermopalaciosgaray
    @guillermopalaciosgaray 4 ปีที่แล้ว

    Great Tutorial! I had some issues like the persons in the comments but in general it is a good video

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว +1

      Thanks for your comment. It's sorry to hear from you are getting an issue. I hope it solved. If not feel free to comment.

    • @bhumitselokar4724
      @bhumitselokar4724 4 ปีที่แล้ว

      @@TechTutorialCN what to do if you wanna save this file to your projects web Content

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      I didn’t get you properly.

    • @bhumitselokar4724
      @bhumitselokar4724 4 ปีที่แล้ว

      @@TechTutorialCN i want to upload this files to
      -webcontent
      --file folder
      in my project
      I am working in eclipse

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      getServetContext().getRealPath() it will return your web content folder

  • @bhumitselokar4724
    @bhumitselokar4724 4 ปีที่แล้ว

    Suppose their is a excel file to upload and save Excel files data to table in MySQL what to do

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว +1

      First you need to read the excel file data and then separate the data. Finally send those data to database according to the column name.

  • @hungnguyenxuan3973
    @hungnguyenxuan3973 4 ปีที่แล้ว +2

    Sir, String path = getServletContext().getRealPath("/"+"files"+File.separator+fileName); = null

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      did you create the folder name "files" in your directory?

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      Please check that you create the folder in your web directory

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      @@mihigoyves what's the issue again?

    • @guillermopalaciosgaray
      @guillermopalaciosgaray 4 ปีที่แล้ว

      Same issue! I did it this way String path= getServletContext().getRealPath("/Files"+File.separator+fileName); but I sends the data to another directory and once the date is in that directory I could not open anything

    • @akashdeshmukh4310
      @akashdeshmukh4310 3 ปีที่แล้ว

      @@TechTutorialCN same issue..its returning null

  • @gajeshtripathi5721
    @gajeshtripathi5721 4 ปีที่แล้ว +4

    is.read(byt); //instead of is.read();

    • @hungtruong3799
      @hungtruong3799 3 ปีที่แล้ว

      Nice brooo!!!

    • @erafif17
      @erafif17 7 หลายเดือนก่อน

      thanks bro it works now

  • @aashishkatwal
    @aashishkatwal 4 ปีที่แล้ว

    Hello sir. I too uploaded the image using the same way and it got uploaded too. But I want to access the image from jsp using img tag and since the BUILD folder is not accessible from the IDE and after deployment of project using of absolute path can cause problems. So what is the solution to it??

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      You don’t need to use the build path folder. Use your regular folder location in your “web” directory. You can access those image if the image not present in that directory, but present in build directory.

  • @sonabasak6999
    @sonabasak6999 4 ปีที่แล้ว +1

    Hello can u make a video of how to populate one drop down list based on a previous drop down list that fetched its value from database. Example: country and state.. And those option values should come from the database. Using only jsp and javascript and mysql.
    Please it is urgent. Searching for this since a long but nothing helped. Thanks!

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      Hey, thanks for your comment. I will upload it as soon as possible.

  • @karanbadre5310
    @karanbadre5310 2 ปีที่แล้ว

    hello bhai file ka path null aa raha he mera plc kay karu me file uplode nahi ho rahi he

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว

      Please double check the context path

  • @shubhangigujar9872
    @shubhangigujar9872 11 หลายเดือนก่อน

    where is the database connection and where you upload data in database sir

    • @TechTutorialCN
      @TechTutorialCN  11 หลายเดือนก่อน

      File uploaded in a files directory

  • @avinashsatpute8100
    @avinashsatpute8100 4 ปีที่แล้ว

    Sir FileNotFoundExcption occurs
    File mane save database but img file not write in web project folder
    WebContent->img

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      please check your path string. and inputstream

  • @udaykiran-ue2vw
    @udaykiran-ue2vw 2 ปีที่แล้ว

    Will it work in deployment so end users can upload any download files?

  • @kushalpal1272
    @kushalpal1272 4 ปีที่แล้ว

    Where is the doPost method? Getting an error while using do post and calling process request.

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      Hi if you use netbeans it will create automatically doGet and doPost method below the procesrequest method. Or you can create doPost method by own self

  • @muhammadshakir8998
    @muhammadshakir8998 2 ปีที่แล้ว

    Sir, after i upload, then i go to the files and open the pdf, the pdf cannot be open

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว

      Might be the stream was not converted properly.

    • @muhammadshakir8998
      @muhammadshakir8998 2 ปีที่แล้ว

      @@TechTutorialCN then, how to fix it?

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว

      Try another file and check if it's working or not.

    • @muhammadshakir8998
      @muhammadshakir8998 2 ปีที่แล้ว

      @@TechTutorialCN other file also have the same problem such as pdf, image and others. How to fix ya?

    • @muhammadshakir8998
      @muhammadshakir8998 2 ปีที่แล้ว

      help me sir

  • @dangvangiangk16_hl17
    @dangvangiangk16_hl17 2 ปีที่แล้ว

    thank u i did it ^^ but i can not open the file after moving it there . help me pls

  • @FlexWithMuscle
    @FlexWithMuscle 3 ปีที่แล้ว

    which jdk u working with

  • @tanmoybanerjee761
    @tanmoybanerjee761 3 ปีที่แล้ว

    Thank you soo much!!

  • @karenolive8914
    @karenolive8914 3 ปีที่แล้ว

    how can I retrieve the image to display it in a jsp page?

    • @TechTutorialCN
      @TechTutorialCN  3 ปีที่แล้ว +1

      As usually you shoe image to html page. Use

    • @karenolive8914
      @karenolive8914 3 ปีที่แล้ว

      @@TechTutorialCN yes. I need help with the path specifically. How will the image path look like
      An example would be great. Thanks

    • @TechTutorialCN
      @TechTutorialCN  3 ปีที่แล้ว

      /folder-name/image-name.jpg like that

    • @karenolive8914
      @karenolive8914 3 ปีที่แล้ว

      @@TechTutorialCN tried this and I get a 404 error.. Request not found. Yet the image has already been uploaded to the folder

    • @TechTutorialCN
      @TechTutorialCN  3 ปีที่แล้ว

      Check the path properly. Go to your build folder to check if the image exists there or not.

  • @manishamaji1201
    @manishamaji1201 4 ปีที่แล้ว

    Do we require any Jar files for running

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      No need any jar file.

    • @manishamaji1201
      @manishamaji1201 4 ปีที่แล้ว

      @@TechTutorialCN thanks for the information

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      Appreciate to help you. Don’t forget to subscribe 🙂

  • @rizwansiddiqui198
    @rizwansiddiqui198 4 ปีที่แล้ว

    Very thanksfull bro

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      glad to hear from u. I wish you subscribe to my channel.

  • @sudipta7643
    @sudipta7643 3 ปีที่แล้ว

    Sir please upload "update image file " video

  • @pankajsahu6931
    @pankajsahu6931 4 ปีที่แล้ว

    Sir file images open nhi ho rhi uploading ke baad

    • @pankajsahu6931
      @pankajsahu6931 4 ปีที่แล้ว

      Sir file to ko display kaise kare images on JSP page

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      In webpage or in your computer?

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

    • @pankajsahu6931
      @pankajsahu6931 4 ปีที่แล้ว

      Sir image upload karne ke baad ye corrupt ho ja rhi hai

    • @pankajsahu6931
      @pankajsahu6931 4 ปีที่แล้ว

      Open hi nhi hori file

  • @zhainhudan1566
    @zhainhudan1566 3 ปีที่แล้ว

    Source Code please....

  • @nitinjangir9038
    @nitinjangir9038 4 ปีที่แล้ว

    getSubmittedFileName mai error hai

    • @nitinjangir9038
      @nitinjangir9038 4 ปีที่แล้ว

      Means error aa rhi hai

    • @TechTutorialCN
      @TechTutorialCN  4 ปีที่แล้ว

      What’s the error you are getting?

    • @nitinjangir9038
      @nitinjangir9038 4 ปีที่แล้ว

      @@TechTutorialCN thanks sir but i solved my wrror.
      This error because of my tomcat 7 and now i download the tomcat 8
      😊

  • @nguyendinhtien5229
    @nguyendinhtien5229 2 ปีที่แล้ว

    if i upload the same file, how to delete existing file before write(file)

    • @TechTutorialCN
      @TechTutorialCN  2 ปีที่แล้ว +1

      Write a logic that will search the file if exist then delete, then upload the file

    • @nguyendinhtien5229
      @nguyendinhtien5229 2 ปีที่แล้ว

      I solved it. And another problem is when clean & build project it will delete image which i just upload. How to avoid delete image that just upload when clean & build