• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in uploading a file

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator





This particular code is uploading the file at /bin folder of tomcat server, but i want this to upload in webapps. i can't understand how it is storing in /bin. please suggest some solution.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are likely using a relative file path to specify the file location. That will put the file some non-deterinistic place as web apps have no concept of "current directory".
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And for goodness sakes, please move this code out of a JSP and put it into a servlet where it belongs.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
please give the correct path where you wanted to create a file in server.
here i given a sample code here

before use, please remove the read only permissions to the web apps folder.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

balakrishnabilla billa wrote:please give the correct path where you wanted to create a file in server


But, of course, hard-coding the path as a string would be a very bad practice indeed.

Rather, determine the location programmatically.

Also, do you really want to upload a file into the web app? Really? What happens when you have to redeploy and update?
 
Jatin sachdev
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for suggestion..............

But as Bear has said

do you really want to upload a file into the web app? Really? What happens when you have to redeploy and update?



where should i upload the file then...?
One more thing i want to ask --- Is there any easy code that i can understand and works accordingly for uploading file?
i dont know actually how to upload file....
please help and give some code snippet for uploading a file....
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the JSP FAQ where file uploads are discussed.

With regards to where to put it, what is the purpose of the file?
 
Jatin sachdev
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
purpose of the file is to authenticate the user on the basis of some information in the file.
I have searched JSP FAQ but the link provided :


On the client

If you want to upload files in conjunction with Commons HttpClient, this introductory article tells how to use FileUpload in conjunction with the Commons HttpClient package.



is not working.............
 
Jatin sachdev
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cant i use simple input sream to upload file...?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jatin sachdev wrote:cant i use simple input sream to upload file...?


The input stream contains a multipart request which is a pain in the rear to parse. No one in their right mind would try to reinvent the wheel when a number of perfectly good libraries that have already solved the problem exist.

Why do you need to write a file to authenticate a user?U
 
reply
    Bookmark Topic Watch Topic
  • New Topic