• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

What is the disadvantage of not mentioning location in MultipartConfig?  RSS feed

 
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to upload very big files greater than 1gb. I am using MultipartConfig and HttpServletRequest.getPart(String) from servlet api. I deployed in my server and tried uploading a file and its working like a charm.

Then I went on reading about MultipartConfig in http://docs.oracle.com/javaee/6/tutorial/doc/gmhal.html. I understood that when large files are uploaded it writes parts of the file to a temporary location when the threshold is reached. And later on we have to delete the temporary files using part.delete().

What if I don't want to mention the temporary location? Will something bad happen to my application while uploading big files? I don't want to mention a temporary location becasue we cant gurantee about the production environment.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chaitanya karthikk wrote:

What if I don't want to mention the temporary location?



It will default to the value that's set for the javax.servlet.context.tempdir context attribute, which is set by the server.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:

It will default to the value that's set for the javax.servlet.context.tempdir context attribute, which is set by the server.


Thanks for the quick response Jaikiran. Is javax.servlet.context.tempdir context attribute set in every application server by default? I use jboss eap 6.x. I my server I dont any such attribute.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran, I did a search in my server root folder and got this location for the temporary files C:\opt\jboss\jboss-eap-6.1\standalone\tmp\work\jboss.web\default-host\file-upload. Thanks for the help.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chaitanya karthikk wrote:
Is javax.servlet.context.tempdir context attribute set in every application server by default?



Yes, that's mandated by the Servlet spec:

Servlet 3.0 spec wrote:
4.8.1 Temporary Working Directories

A temporary storage directory is required for each servlet context. Servlet containers
must provide a private temporary directory for each servlet context, and make it
available via the javax.servlet.context.tempdir context attribute. The objects
associated with the attribute must be of type java.io.File.
The requirement recognizes a common convenience provided in many servlet engine
implementations. The container is not required to maintain the contents of the
temporary directory when the servlet container restarts, but is required to ensure
that the contents of the temporary directory of one servlet context is not visible to
the servlet contexts of other Web applications running on the servlet container.

 
Bartender
Posts: 20724
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:

chaitanya karthikk wrote:

What if I don't want to mention the temporary location?



It will default to the value that's set for the javax.servlet.context.tempdir context attribute, which is set by the server.



Which, in turn, is set by the JVM and can be overridding the "java.io.tmpdir" JVM system property. Been there, did that. This is for Tomcat, mind you, but expect most JEE servers to do likewise.

So your temporary file directory isn't set at the application level. Or strictly speaking, even at the server level. It's at the JVM level and can be set by the production operations staff to wherever is most suitable.

That's assuming that the standard java.io tempfile facilility is being used to allocate and create the tempfiles. Which most of the stock upload handlers will be using.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!