22) JSP Integration.

 

back to main index

 

Xload code can easily be integrated into a JSP. Simply place scriplets inside the JSP to allow Xload code to be executed. No special formatting, code addition or alteration regarding exceptions thrown need be done, as the JSP's _jspService method throws the same exceptions as its Servlet counterpart. A JSP can double up as a file upload/management processing component and a response component incorporating processing logic from the file upload/management performed.

 

Below is a simple example of JSP code that performs a file upload with an appropriate response.

 

 

<%@page contentType="text/html" import="com.gubutech.xload.*;"%>

<%@page pageEncoding="UTF-8"%>

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>

      <head>

        <title>JSP File Upload/Management</title>

           <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

      </head>

 

      <body> 

 

<%

XloadManager xman = new XloadManager(request);

xman.target("file1", "uploaded", 1024);

xman.upload();

XloadFileUpload upload = xman.getFileUpload("file1");

if(upload.isAnUploadFailure()){

%>

 

<font class="fontfail">

Unfortunately your file failed to upload due to one of the following reasons:<br><br>

 

<ul>

   <li>Your file was too large (1mb max.)</li>

   <li>The path to your file was incorrect</li>

   <li>Your file field was blank</li>
</ul>

</font>

 

<%}else{%>

 

<font class="fontpass">

Your file was successfully uploaded.

</font>

 

<%}%>

 

 

      </body>

    </html>

 

 

 

 

 

 

 

where:

request - HttpServletRequest object.

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

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

 

Obviously, this example can be greatly expanded on and can become much more sophisticated and efficient but it shows how both processing and response can be combined. Gubutech microsystems are developing a TAG based interface that will allow JSP Developers to just use purely custom TAGS to process file uploads and manage files/folders on their systems. Processing logic will be built in with the ability to override this logic being available.

 

 

back to main index

top of page

 

 

 

 

 

 

© Gubutech(Xload) 2006  (v1.2)