org.apache.struts.upload.MultipartRequestHandler Java Examples

The following examples show how to use org.apache.struts.upload.MultipartRequestHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpLoadFileForm.java    From jivejdon with Apache License 2.0 6 votes vote down vote up
/**
 * Check to make sure the client hasn't exceeded the maximum allowed upload
 * size inside of this validate method.
 */
public void doValidate(ActionMapping mapping, HttpServletRequest request, List errors) {

	// has the maximum length been exceeded?
	Boolean maxLengthExceeded = (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
	if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {

		errors.add("exceed the upload max length");

	} else if (theFile != null) {
		// retrieve the file name
		String fileName = theFile.getFileName();
		if (!uploadHelper.canBeUpload(fileName))
			errors.add(new ActionMessage("illegal file type! "));
	}

}
 
Example #2
Source File: AccountFaceFileForm.java    From jivejdon with Apache License 2.0 6 votes vote down vote up
/**
 * Check to make sure the client hasn't exceeded the maximum allowed upload
 * size inside of this validate method.
 */
public void doValidate(ActionMapping mapping, HttpServletRequest request, List errors) {

	// has the maximum length been exceeded?
	Boolean maxLengthExceeded = (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
	if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {

		errors.add("exceed the upload max length");

	} else if (theFile != null) {
		// retrieve the file name
		String fileName = theFile.getFileName();
		if (!uploadHelper.canBeUpload(fileName))
			errors.add(new ActionMessage("illegal file type! "));
	}

}
 
Example #3
Source File: ComAjaxServletBase.java    From openemm with GNU Affero General Public License v3.0 4 votes vote down vote up
private void setMultipartHandlerClass(HttpServletRequest request, Class<? extends MultipartRequestHandler> cls) {
    request.setAttribute(Globals.MODULE_KEY, new ModuleConfigImpl());
    request.setAttribute(Globals.MULTIPART_KEY, cls.getName());
}