Brief introduction
The WEB portal provides a central gateway for users to access a variety of resources and services. At the same time, they provide a platform for users to share resources with other users. From photos to audio and video files to scientific datasets for research, users can share anything. As a result, file uploads are a basic prerequisite for Web portals.
Today's Web portals are largely dependent on Java portlet technology. Although many developers using Ajax have a variety of File upload progress bar solutions, we have not heard of a portlet based. This article shows how to develop an Ajax-based file upload portlet that displays the progress bar for the file upload process. This portlet is especially useful for people who want to share large audio, video, and scientific files.
To keep up with the progress of this article, you should be familiar with the use of Java Servlets and JavaServer Pages (JSPs) for WEB development. Also, you must understand the development of portals and portlet technologies. Of course, if you're not very proficient with portlet technology, don't give up this article now, because you'll see a brief introduction to Portlet technology in this article, and some useful resources to help you accelerate your learning process.
Before you test the file upload portlet given in this article, consider trying to use a portal framework that complies with the JSR 168 specification, such as Ibm®websphere®portal Server, Apache Pluto, EXo platform, or Liferay portal 。 We use the Apache Pluto 1.0.1, JDK 5.0 Update 10, and Apache Ant Version 1.6.5 in this article.
Basic concepts of Portlets
In general, a portlet can be treated as a Web component. Portlets are similar to servlet, but the former are more concerned with the presentation layer of the application. The typical output of a portlet is an HTML fragment that can then be assembled by the Web portal. The portlet itself is managed by the Portlet container. The main features of Portlets include:
Multi-mode: Portlets can have different views in different modes. For example, in addition to viewing mode, the portlet supports edit mode so that users can set their own preferences.
Multiple window states: Portlets can be minimized, maximized, and so on.
Customizable parameters: Portlets can define parameters that can be customized by the user.
For more detailed information about portlets, you can refer to the Java portlet specification 1.0,JSR (JSR 168 later version of JSR 286 is expected to be released in 2007, including some improvements, such as Port Let communication and Portlet filters). For links, see resources.
Start creating the File upload Portlet
The cornerstone of the file upload portlet is the Apache Commons FileUpload package (also called fileupload in this article). In addition to supporting file uploads within the servlet, the Apache Commons fileupload Version 1.1 package also supports file uploads in portlets. This article uses the Apache Commons fileupload version 1.2.
Basically, the development file upload progress bar takes two steps:
Retrieving the file upload process on the server side
Retrieving and displaying client-side file uploads from the portal Server