19) Integrate into Struts.

 

back to main index

 

 

Integration of Xload into the Struts architecture is easy. To integrate into Struts then simply use Xload code within a Struts Action class. You cannot use Struts ActionForm objects to hold request information as the request will be of multipart/form-data type. Below shows an example of a Struts Action class that will use Xload to upload a file. Xload specific code is in black font.

 

 

 

package strutsactions;

 

import org.apache.struts.action.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import com.gubutech.xload.*;

import java.util.*;

 

 

 

public class UploadFile extends Action{

   

public UploadFile(){

}

 

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{

   

XloadManager xman = new XloadManager(request);

xman.target("file", "uploaded");

xman.upload();

XloadFile f1 = xman.getFile("file1");

}

 

 

}

 

 

 

 

where:

request - HttpServletRequest object.

uploaded - Directory to upload files to (relative to the web application directory).

File - File parameter inside html (or other) form.

   

 

As can be seen from above it is relatively simple to use the Struts architecture alongside Xload. The only real point to remember is that you cannot read the body of the request prior to using Xload as this will obviously interfere with Xload reading the request itself.

 

back to main index

top of page

 

 

 

 

© Gubutech(Xload) 2006  (v1.2)