What I want to do:
- check for a "legal" file extension
(e.g. only loading gif, jpg, png)
- check for the sizes of the files
(e.g. only upload up to 20 kb)
- save the file to disk.
The problems i'm clueless about:
- how to find the files within the request body
- how to determine the size upfront
- how to decode the files back to the binary format
For more info visit the following link
<INPUT TYPE="file" NAME="me.jpg">
<INPUT TYPE="submit" VALUE="upload">
Then in order to code a servlet being able of processing the POST data to extract the encoded file you can take a look to the required format in the RFC-1867. ( http://www.ietf.org/rfc/rfc1867.txt ).
If you prefer to use a library to do it instead of code your own servlet, here you have a number of libraries available:
.-Jason Hunter's MultipartRequest at http://www.servlets.com
.-CParseRFC1867 (available from http://www.servletcentral.com).
.-There are MIME-parsing routines in JavaMail
.-www.JSPSmart.com has a free set of JSP for uploading and downloading files.
thx for the info. I have the problem, that I cannont deploy any Java packages to the production server (that is a political, not a technical restriction). Could I extract the class(es) needed from the oreilly package? What classes would that be?
Originally posted by Shubhrajit Chatterjee:
for example you can look at the following package ...
I have the problem, that I cannont deploy any Java packages to the production server (that is a political, not a technical restriction). Could I extract the class(es) needed from the oreilly package? What classes would that be?
i think u must have dwnloaded the com.oreilly... package. u must be having a directory structure like com->oreilly->servlet...now on the server u can make a similar directory structure inside the servlet directory...
hope this helps...it did for me...still if that doesnt..just revert...
(A doesn't cost anything...keep smiling)
You've got an interesting problem. By that I mean: If you can't deploy any java packages on your production server, how do the Mordacs in your organization expect you to deploy your own application? (Mordac: Preventer of Information Services)
Anyways... If you're able to deploy WAR files (your application) then you can utilize the WEB-INF/lib directory within this package to 'hide' the cos.jar file. It would stil be a 'java package', but it would be 'part' of your application. You can make the political case that it won't work without it.
thx for the help. I need to elaborate a little. The server I'm deploying to is a Lotus Domino R5. It has only a JRE 1.1.8 and no real deployment mechanism for all the nice J2EE stuff. So I can put small servlets in the servlet directory, that's it more or less.
So how would I go with the com.oreilly.servlet. I asume the book has the source-code. I probably could migrate the one function I need (and it's depencencies) into my source file. However I'm a VERY GREEN Java Horn , so how to go?
If you think education is expensive - try ignorance!