Use static final fields RequestTrans.GET and RequestTrans.POST for storing HTTP method.

This commit is contained in:
hns 2004-03-10 15:00:10 +00:00
parent 092070bb73
commit 11b45fe9c4
2 changed files with 14 additions and 12 deletions

View file

@ -28,6 +28,9 @@ import java.util.*;
public class RequestTrans implements Externalizable {
static final long serialVersionUID = 5398880083482000580L;
public final static byte GET = 0;
public final static byte POST = 1;
// the uri path of the request
public String path;
@ -38,7 +41,7 @@ public class RequestTrans implements Externalizable {
private Map values;
// the request method - 0 for GET, 1 for POST
private byte httpMethod = 0;
private byte httpMethod = GET;
// timestamp of client-cached version, if present in request
private long ifModifiedSince = -1;
@ -58,7 +61,7 @@ public class RequestTrans implements Externalizable {
* Create a new Request transmitter with an empty data map.
*/
public RequestTrans() {
httpMethod = 0;
this(GET);
values = new SystemMap();
}
@ -122,14 +125,14 @@ public class RequestTrans implements Externalizable {
* Return true if this object represents a HTTP GET Request.
*/
public boolean isGet() {
return httpMethod == 0;
return httpMethod == GET;
}
/**
* Return true if this object represents a HTTP GET Request.
*/
public boolean isPost() {
return httpMethod == 1;
return httpMethod == POST;
}
/**

View file

@ -32,8 +32,6 @@ import javax.servlet.http.*;
* via RMI. Subclasses are either one servlet per app, or one servlet that handles multiple apps
*/
public abstract class AbstractServletClient extends HttpServlet {
static final byte HTTP_GET = 0;
static final byte HTTP_POST = 1;
// host on which Helma app is running
String host = null;
@ -100,7 +98,7 @@ public abstract class AbstractServletClient extends HttpServlet {
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
execute(request, response, HTTP_GET);
execute(request, response, RequestTrans.GET);
}
/**
@ -114,7 +112,7 @@ public abstract class AbstractServletClient extends HttpServlet {
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
execute(request, response, HTTP_POST);
execute(request, response, RequestTrans.POST);
}
protected void execute(HttpServletRequest request, HttpServletResponse response,
@ -195,6 +193,7 @@ public abstract class AbstractServletClient extends HttpServlet {
reqtrans.set(nextKey, nextPart);
}
} catch (Exception badCookie) {
// ignore
}
}