• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

What is the disadvantage of not mentioning location in MultipartConfig?

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Saloon Keeper
Posts: 28419
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic