Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Save image from Servlet  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1054
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to save an image from a Servlet like this:



It works well in this case but I want to save the pics in a folder called pics inside the WebPages folder like this:



Any idea, please?

Regards, Isaac
 
salvin francis
Bartender
Posts: 1479
21
Eclipse IDE Google Web Toolkit Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do you want to save it in the webpages folder ?
Consider this, you want to deploy a new war to the server, what is going to happen ?

By the way, you might want to look at ServletContext.getRealPath() method.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saving anything into the web context is a really bad idea as has already been pointed out. It will create many problems when redeploying. Save any files outside the web context.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!