private HttpServletRequest req;
private HttpServletResponse resp;
private String method, path;
- private URL url;
- private Map<?, ?> props = new HashMap();
+ private URL url, context;
+ private MultiMap<String, String> params = null;
public J2eeRequest(ServletConfig cfg, HttpServletRequest req, HttpServletResponse resp) {
this.cfg = cfg;
q = "";
try {
url = new URL(scheme, host, port, req.getContextPath() + req.getServletPath() + pi + q);
+ context = new URL(scheme, host, port, req.getContextPath());
} catch(MalformedURLException e) {
throw(new Error(e));
}
path = path.substring(1);
}
- public Map<?, ?> props() {
- return(props);
- }
-
- public ServerContext ctx() {
- return(new J2eeContext(cfg, req, resp));
- }
-
public SocketAddress remoteaddr() {
try {
- return(new InetSocketAddress(InetAddress.getByName(req.getRemoteAddr()), req.getRemotePort()));
+ /* Apparently getRemotePort returns -1 when running on Tomcat over AJP. */
+ int port = req.getRemotePort();
+ if(port < 0)
+ port = 0;
+ return(new InetSocketAddress(InetAddress.getByName(req.getRemoteAddr()), port));
} catch(UnknownHostException e) {
/* req.getRemoteAddr should always be a valid IP address,
* so this should never happen. */
return(url);
}
+ public URL rooturl() {
+ return(context);
+ }
+
+ public ServerContext ctx() {
+ return(ThreadContext.current().server());
+ }
+
public String method() {
return(method);
}
}
public MultiMap<String, String> params() {
- return(null);
+ if(params == null)
+ params = Params.stdparams(this);
+ return(params);
}
protected void backflush() {