cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload - Calling bls via JSP

Former Member
0 Kudos

I'm using the following jsp to upload a document and call a bls transaction

<%

boolean isMultipart = DiskFileUpload.isMultipartContent(request);

DefaultFileItemFactory factory = new DefaultFileItemFactory();

DiskFileUpload upload = new DiskFileUpload(factory);

List /* FileItem */ items = upload.parseRequest(request);

Iterator iter = items.iterator();

while (iter.hasNext()) {

    FileItem item = (FileItem) iter.next();

          if (!item.isFormField()) {

                    String fileName = item.getName();

                    String contentType = item.getContentType();

                    File uploadedFile = new File("\\\\Livadmmdvci1\\MII_Backups\\Upload\\" + fileName.substring(fileName.lastIndexOf("\\") + 1));

                    item.write(uploadedFile);

                    String site = new String("/XMII/Runner?Transaction=CustomerComplaintTracking/UploadFile-b&FILETYPE=" + contentType + "&FILENAME=" + (fileName.substring(fileName.lastIndexOf("\\") + 1)));

                    response.sendRedirect(site);

          }

}

%>

However the response.sendDirect(site) line is routing my application to a page displaying the output xml from my bls. I'm wondering if there is a way to call my transaction via the runner without using the response.sendDirect? I would like to upload the document and call the transaction and than direct the application back to the original screen. Any help is appreciated. Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Scott, you can achieve what to want to do with a post to an iframe located in your page.

Then on the reply from the server, you can even put a small javascript which would call a function from the source page to let the page know that the files have been uploaded (or not).

Cheers,

Arnaud

Former Member
0 Kudos

Thanks for the response. I changed the target of my form to my iframe and was successfully able to upload the document without leaving my original page.

However when the jsp executes the following line

response.sendRedirect(site);

it's redirecting the iframe page to my xml output, and I can't perform any javascript. How do I go about performing the BLS execution


/XMII/Runner?Transaction=CustomerComplaintTracking/UploadFile-b&FILETYPE=" + contentType + "&FILENAME=" + (fileName.substring(fileName.lastIndexOf("\\") + 1))

without using the response.sendRedirect(site) line?

Thanks

Former Member
0 Kudos

Hello, you need to complete the url of the transaction posting the file

/XMII/Runner?Transaction=CustomerComplaintTracking/UploadFile-b&FILETYPE=" + contentType + "&FILENAME=" + (fileName.substring(fileName.lastIndexOf("\\") + 1))

and the transction.

Add a string output parameter to the transaction, let's say OutputString (Type Output), define your html content inside, and set the outputtype of the trantion to Text/HTML

which means that you have to add "&OutputParameter=OutputString&Content-Type=Text/HTML" with the proper escaping to you site variable.

then in the transaction and OutputSting, if you put something like:

<html>

<script>alert('Hello')</script>

</html>

it should work.

Cheers,

Arnaud

Former Member
0 Kudos

Just a small comment, it's that you are using a jsp which is able to take care of several documents but which would in fact redirect you on the first document while keeping processing and posting the documents to the Transactions, not probably the desired effect, but it should work with one document, if it is provided, if nothing is provided, nothing is returned...

Answers (0)