Add support for res.getServletResponse() and res.servletResponse
This commit is contained in:
parent
9778df82eb
commit
0143f7a9dc
5 changed files with 38 additions and 20 deletions
|
@ -20,6 +20,7 @@ import helma.util.Base64;
|
||||||
import helma.util.SystemMap;
|
import helma.util.SystemMap;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -44,8 +45,9 @@ public class RequestTrans implements Serializable {
|
||||||
public final static String EXTERNAL = "EXTERNAL";
|
public final static String EXTERNAL = "EXTERNAL";
|
||||||
public final static String INTERNAL = "INTERNAL";
|
public final static String INTERNAL = "INTERNAL";
|
||||||
|
|
||||||
// the servlet request, may be null
|
// the servlet request and response, may be null
|
||||||
HttpServletRequest request;
|
HttpServletRequest request;
|
||||||
|
HttpServletResponse response;
|
||||||
|
|
||||||
// the uri path of the request
|
// the uri path of the request
|
||||||
public String path;
|
public String path;
|
||||||
|
@ -85,9 +87,10 @@ public class RequestTrans implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Create a new request transmitter with the given data map.
|
* Create a new request transmitter with the given data map.
|
||||||
*/
|
*/
|
||||||
public RequestTrans(HttpServletRequest request) {
|
public RequestTrans(HttpServletRequest request, HttpServletResponse response) {
|
||||||
this.method = request.getMethod();
|
this.method = request.getMethod();
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
this.response = response;
|
||||||
values = new SystemMap();
|
values = new SystemMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +127,14 @@ public class RequestTrans implements Serializable {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Servlet response for this request.
|
||||||
|
* Returns null for internal and XML-RPC requests.
|
||||||
|
*/
|
||||||
|
public HttpServletResponse getServletResponse() {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hash code is computed from the session id if available. This is used to
|
* The hash code is computed from the session id if available. This is used to
|
||||||
* detect multiple identic requests.
|
* detect multiple identic requests.
|
||||||
|
|
|
@ -18,6 +18,7 @@ package helma.framework;
|
||||||
|
|
||||||
import helma.objectmodel.db.Transactor;
|
import helma.objectmodel.db.Transactor;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -93,6 +94,14 @@ public class ResponseBean implements Serializable {
|
||||||
res.reset();
|
res.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ServletResponse instance for this Response.
|
||||||
|
* Returns null for internal and XML-RPC requests.
|
||||||
|
*/
|
||||||
|
public HttpServletResponse getServletResponse() {
|
||||||
|
return res.getServletResponse();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,6 +18,8 @@ package helma.framework;
|
||||||
|
|
||||||
import helma.framework.core.Skin;
|
import helma.framework.core.Skin;
|
||||||
import helma.util.*;
|
import helma.util.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -111,13 +113,13 @@ public final class ResponseTrans implements Serializable {
|
||||||
public transient String error;
|
public transient String error;
|
||||||
|
|
||||||
// the res.data map of form and cookie data
|
// the res.data map of form and cookie data
|
||||||
private transient Map values;
|
private transient Map values = new SystemMap();;
|
||||||
|
|
||||||
// the res.handlers map of macro handlers
|
// the res.handlers map of macro handlers
|
||||||
private transient Map handlers;
|
private transient Map handlers = new SystemMap();;
|
||||||
|
|
||||||
// the res.meta map for meta response data
|
// the res.meta map for meta response data
|
||||||
private transient Map meta;
|
private transient Map meta = new SystemMap();;
|
||||||
|
|
||||||
// the request trans for this response
|
// the request trans for this response
|
||||||
private transient RequestTrans reqtrans;
|
private transient RequestTrans reqtrans;
|
||||||
|
@ -128,24 +130,12 @@ public final class ResponseTrans implements Serializable {
|
||||||
// the appliciation checksum to make ETag headers sensitive to app changes
|
// the appliciation checksum to make ETag headers sensitive to app changes
|
||||||
long applicationChecksum;
|
long applicationChecksum;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ResponseTrans object.
|
|
||||||
*/
|
|
||||||
public ResponseTrans() {
|
|
||||||
super();
|
|
||||||
message = error = null;
|
|
||||||
values = new SystemMap();
|
|
||||||
handlers = new SystemMap();
|
|
||||||
meta = new SystemMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ResponseTrans object.
|
* Creates a new ResponseTrans object.
|
||||||
*
|
*
|
||||||
* @param req ...
|
* @param req the RequestTrans for this response
|
||||||
*/
|
*/
|
||||||
public ResponseTrans(RequestTrans req) {
|
public ResponseTrans(RequestTrans req) {
|
||||||
this();
|
|
||||||
reqtrans = req;
|
reqtrans = req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +171,14 @@ public final class ResponseTrans implements Serializable {
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ServletResponse instance for this ResponseTrans.
|
||||||
|
* Returns null for internal and XML-RPC requests.
|
||||||
|
*/
|
||||||
|
public HttpServletResponse getServletResponse() {
|
||||||
|
return reqtrans.getServletResponse();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the response object to its initial empty state.
|
* Reset the response object to its initial empty state.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -594,7 +594,7 @@ public final class Application implements IPathElement, Runnable {
|
||||||
throw stopped;
|
throw stopped;
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
errorCount += 1;
|
errorCount += 1;
|
||||||
res = new ResponseTrans();
|
res = new ResponseTrans(req);
|
||||||
res.writeErrorReport(name, x.getMessage());
|
res.writeErrorReport(name, x.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if (primaryRequest) {
|
if (primaryRequest) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
||||||
protected void service (HttpServletRequest request, HttpServletResponse response)
|
protected void service (HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
|
||||||
RequestTrans reqtrans = new RequestTrans(request);
|
RequestTrans reqtrans = new RequestTrans(request, response);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// get the character encoding
|
// get the character encoding
|
||||||
|
|
Loading…
Add table
Reference in a new issue