• 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

Creating a folder in the server

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there. I use Eclipse with Tomcat 6. I want to create a JSP where one can upload a file and then view it as a list of files in the directory. I have managed to accomplish upload a file to a shared folder on LAN and view it as a http page. (In server.xml of Tomcat I have context folder path to that shared folder). Now I want to make it such that anyone in across globe (not only on LAN) can create a folder there.. Any suggestions ?? The code to upload goes something like this. I got it in google search. I have done some minor corrections though. I know I must have used servlets instead. Please help.



Also, in line 25, substring is taken till '\n', but when I printed 'file' (from line 19) I could not figure out '\n' (new line) . I mean, it was like continuous chunk of information. Please tell why its used there.
 
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
First step: move the code out of a JSP and into a servlet.
 
Prabhat Kumar N
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:First step: move the code out of a JSP and into a servlet.



Yes I know. I told that earlier. But can someone help me adjusting the code for storing in folder other than shared? I can later do adjustments for servlets.
 
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
You'd be better served to use one of the common 3rd party libraries like Commons Upload. See the FAQ for more details.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You'd be better served to use one of the common 3rd party libraries like Commons Upload. See the FAQ for more details.


I agree with Bear, why would you choose to do all of the low level work where some external "tested/approved" library is made for just that.
 
Prabhat Kumar N
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You'd be better served to use one of the common 3rd party libraries like Commons Upload. See the FAQ for more details.



Thank you for the idea. But still I have to use, at some point of time. What location must I write here if the server is remote ? I mean, if I access the server by "http://111.111.111.111/Theloc". In the server end, in server.xml, in context, 'Theloc' is pointing to C:/Program Files of that server PC. I want to create my folder in that C:/Program Files. SO what location do I enter ? Please help.
 
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
Where on the server do you want to write the uploaded file?
 
Prabhat Kumar N
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Where on the server do you want to write the uploaded file?



I told in the above post.

if I access the server by "http://111.111.111.111/Theloc". In the server end, in server.xml, in context, 'Theloc' is pointing to C:/Program Files of that server PC. I want to create my folder in that C:/Program Files. SO what location do I enter ? Please help.



I want the folder to be created in "C:/Program Files" of the Tomcat installed PC which is acting as server.
 
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
[Please don't ninja-edit your posts]
 
Prabhat Kumar N
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:/unsubscribes



I did not get you. I want the folder to be created in "C:/Program Files" of the Tomcat installed PC which is acting as server. I access it "http://111.111.111.111/Theloc" When I enter this I get list of directories in "C:/Program Files". "Theloc" is pointed to "C:/Program Files" in server.xml in server PC using context.
 
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
"/unsubscribes" means I had lost all interest in the topic based upon your unwillingness to help us help you. Since you "ninja-edited" your post to answer my question, I'll give it another chance.

File I/O has nothing to do with URLs. If you want to save to a folder, simply reference the folder the same way as any other file I/O.
 
Prabhat Kumar N
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. I want to reference to that folder but its like this. A client accesses the page using "http://111.111.111.111/TheLoc" and reads the list of directories pointed by 'TheLoc' ie C:\Program Files of server. In case he opens another JSP which allows him to upload a file to C:\Program Files of the server. If the location is just given as C:\Program Files will it not upload to C:\Program Files of his PC ?
 
mark benz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlets run on the server, whatever you write in it become local to that server. As Bear referenced "File I/O has nothing to do with URLs"

btw you can use Commons file upload, and still do your new File() thing
 
Prabhat Kumar N
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Bear and Mark. Thats what I wanted to know
 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic