80 likes | 219 Views
File Upload. &. Download. using. My SQL database. By:. Anand Shankar. ACIIL. File Upload. Client Browser. Multipart Format. Database Server (My SQL Database). Attach a file. Class Diagram for Upload Beans. Why I have created a separate component.
E N D
File Upload & Download using My SQL database By: Anand Shankar ACIIL
File Upload Client Browser Multipart Format Database Server (My SQL Database) Attach a file
Why I have created a separate component Design patterns and software development rules say… • Make a separate component for that codes which are used many times in your application. • These components should be easy to use. • Write proper documentation and class diagram for every component. • Your separate designed component should be flexible and can be used in another application also. • Avoid to write Java code in JSP pages. • The best JSP is, in which a single line of java code is not written.
Flow Diagram • It follows MVC architecture of Design Pattern. • All the requests and responses go through a Central Controller. • Central Controller is responsible for all the activities of uploading and downloading and later it will work for whole QMS application as a Controller.
Client (Administrative) Client Send file Request to Download files Download files Central Controller Beans Interacts with Beans Retrieve file from database Beans Store file in database in Binary format
How can be used Upload Beans Very Simple steps to use this… • Put anandUpload1.0.jar file in WEB-INF/lib dir. • Set <form enctype="multipart/form-data" > of your .jsp or .html file. • Add tag <input type="file" name="file" /> in this .jsp or .html file. • Write code in your Servlet… • CentralControl cc = new CentralControl(); • Hashtable hs=cc.processRequest(request, response); • Your all the fields values of form will be returned in a Hashtable and you can simply get these values as… • String name=(String)hs.get("name");