Can someone help me with this?
The java class I wrote lookes like this:
Code: Select all
package com.ebasetech.ufs.customfunctions;
/**
* Class : PostForm
*
* Function : Post data
* Date: 5-10-2007
*
*/
import java.util.*;
import org.nfunk.jep.*;
import com.ebasetech.ufs.function.*;
import com.ebasetech.ufs.kernel.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
public class PostForm extends UFSCustomFunction {
/**
* Constructor
*/
public PostForm(UFSFormInterface formInterface) {
super(formInterface);
numberOfParameters = 1;
}
/**
* Reads data form stack
* Pushes data into stack
* @throws FormException, ParseException
*/
public void run(Stack inStack) throws FormException, ParseException {
checkStack(inStack);
Object param1 = inStack.pop(); //URL with parameters
if(param1 instanceof String) {
String url = param1.toString();
try {
HttpClient httpclient = new HttpClient();
PostMethod post = new PostMethod(url);
try {
int result = httpclient.executeMethod(post);
if(result == 200 || result == 201 || result == 302)
inStack.push("OK");
else {
String error = Integer.toString(result) + " " + post.getResponseBodyAsString();
inStack.push(error);
}
} finally {
post.releaseConnection();
}
} catch(Exception e) {
throw new FormException (e.getMessage());
}
} else {
throw new ParseException ("Invalid parameter type");
}
}
}