Situation: You and your partners need to exchange business messages, but have different infrastructure, staff, skills, budget and priorities. It is also important that message formats remain in the control of the group.
Http uploads decouple all technologies, therefore allowing all the required flexibility at all levels.
This setup requires an http POST server and an http POST client (the simplest is a browser and an html form)
Free HttpPostServer download. | Free HttpPostClient download
Client activities are described in Automating web uploads.
Server activities follow below.
HttpPostServer and jsp
Jsp (Java Server Page) is a web technology most web developers are familiar with, it turns ordinary html into powerful web templates, by allowing the server to insert content at run time.
Jsp runs in java application servers, the father of them all is Apache Tomcat.
There are many others, some are free and some are not, on average they all are better than one needs.
For information:
*
IBM provides Websphere Application Server
* SUN provides Java System Application Server.
* SUN initiated java.net and they have come up with GlassFish, the latest Application Server project.
HttpPostServer is a standalone component; you only copy one file in a standard location and you are ready.
This makes it very easy to deploy; for inforamtion in Tomcat you copy it in ./shared/lib.
Being a component, you use it more than you code it, there is no framework to develop skills on.
This makes it very easy to implement, the sample below shows you how.
Sample JSP Page
<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="com.compomentis.httppostserver.HttpPostServer" %>
<%@page import="java.util.Enumeration" %>
<%@page import="java.util.Vector" %>
<%
// This is where files will be persisted
String outputDirectory = System.getProperty("user.home") + "/home/SheepServerData";
// This is an upload size limit in bytes
int MAXSIZE = 100000;
// Here we simply ensure this is a valid POST operation (coming from a form not a link)
String method = request.getMethod();
if(method.equals("POST"))
{
try
{
//------------------------------------------------------------------------------------
// Upload fields - HttpPostServer can receive fields and/or files.
// Note: request is a standard jsp object.
//------------------------------------------------------------------------------------
HttpPostServer httpPostServer = new HttpPostServer(request, outputDirectory, MAXSIZE);
httpPostServer.setLogLevel(2); // keep logging reasonably quiet
httpPostServer.upload(); // retrieve the actual data
//------------------------------------------------------------------------------------
// Prepare the response
// Set the response's Content-Type as text/plain
// Note: To let Internet Explorer display the response in the browser window, we also set
//
Content-Disposition with the appropriate extension in filename.
// Another Note: out is a standard jsp object.
//------------------------------------------------------------------------------------
out.clear();
response.addHeader("Content-Type", "text/plain");
response.addHeader("Content-Disposition", "inline; filename=a.txt");
//------------------------------------------------------------------------------------
// Fields are accessible via plain-english methods.
//------------------------------------------------------------------------------------
Vector fieldNames = httpPostServer.getInputFieldNames();
Vector fieldValues = httpPostServer.getInputFieldValues();
Vector fileNames = httpPostServer.getInputFileNames();
Vector fileTypes = httpPostServer.getInputFileContentTypes();
Vector fileValues = httpPostServer.getInputFilePath();
//------------------------------------------------------------------------------------
// echo fields as name=value pairs
//------------------------------------------------------------------------------------
for(int i=0; i < fieldNames.size();i++)
{
out.write(fieldNames.get(i) + "=" + fieldValues.get(i));
out.newLine();
}
//------------------------------------------------------------------------------------
// echo file as name=type=filename triplets (we don't echo the actual content)
//------------------------------------------------------------------------------------
for(int i=0; i < fileNames.size();i++) {
out.write(fileNames.get(i) + "=" + fileTypes.get(i)+ "=" + fileValues.get(i));
out.newLine();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
%>
Benefits
The ability to accept http uploads directly into an application server is an important asset.
It provides your IT with
-
A universal, supplier-agnostic and long-lasting communication method.
http and java are now available everywhere.
-
A fast, reliable, auditable and secure communication method.
The sample above has throughput in excess of 400MB per minute on a standard desktop.
Because it is your page, you know and control exactly what can or cannot be done with it.
Because jsp is "plain text", it is auditable without requiring special IT software and skills.
-
Simpler business workflows, there are no IT-for-IT steps involved.
In one page, the fields and files are already on the server ready to be processed.
-
Simpler IT workflows, using a ubiquitous standard guarantees no precious time
is wasted in recruitment, training and re-design with every project and staff
move.
-
Better partnering.
This is the single most important point, no other communication method gives you the guarantee that everyone can use it regardless of budget and skill..
|
|
|