I am interested in images but the question is quite general. I am doing it thusly :
private static final SecureRandom RANDOM = new SecureRandom();
private static final int FILENAMElENGTH = 73; // a guess
private static String nextId() { // synchronized ?
return new BigInteger(FILENAMElENGTH, RANDOM).toString(32);
} // https://stackoverflow.com/a/41156/281545
Questions :
- Are there pros and cons in storing the files with the session id + a timestamp ? Pros as in use this info later and cons as in security
- Are there any standard (see servlet API or Java) way of generating a name ? Any standard practices ? Any container specific tips (glassfish and tomcat)
I understand that keeping the original filename, the username etc can lead to security holes
Related :
<img src="${sessionScope.photo.path}" />
things (which indeed display the session - ooops!) – Mr_and_Mrs_D