0

I am trying to change the default location for the Part "write" function.

I tried directly in my servlet : @MultipartConfig(location="/web/files/") and also in my web.xml file :

<servlet-name>pictureController</servlet-name>
<servlet-class>fr.beans.PictureController</servlet-class>
<multipart-config>
    <location>/web/files</location> 
    <max-file-size>20848820</max-file-size>
    <max-request-size>418018841</max-request-size>
    <file-size-threshold>1048576</file-size-threshold>
</multipart-config>

Then to save the uploaded file :

    file.write(file.getSubmittedFileName());

But neither are working, it keeps saving the files in a generated Glassfish directory, something like /opt/glassfish-4.1.1/glassfish/domains/domain1/generated/jsp/

Is there something wrong with my configuration?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Pierre
  • 4,976
  • 12
  • 54
  • 76
  • 1
    How is this custom **servlet** related to JSP and JSF (modern versions of JSF do not work with JSP btw) – Kukeltje Jan 11 '18 at 16:37
  • 1
    In case you can't find back your previously asked questions, peek here: https://stackoverflow.com/users/206808/piero?tab=questions You can get there by clicking anywhere your username or profile picture appears as a link. – BalusC Jan 11 '18 at 16:47
  • Yes as explained in your answer : Part#write() interprets the path relative to the temporary storage location defined in @MultipartConfig(location). So what if I want to use the Multipart config? You're saying my question has already been answered but I disagree. And the Javadoc states that the write method can be used for this... IWhy doesn't it work when specifying MultipartConfig(location) is what I am asking... – Pierre Jan 11 '18 at 17:54
  • 1
    Read the last comment (might be hidden initially) on the answer (by @BalusC) in https://stackoverflow.com/questions/14843615/java-io-filenotfoundexception-when-writing-uploaded-file-to-disk-via-getrealpath Unfortunately the link it points to does not exist anymore, but it seems related to your 'problem' – Kukeltje Jan 12 '18 at 11:05

0 Answers0