summaryrefslogtreecommitdiffhomepage
path: root/src/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java')
-rw-r--r--src/java/nginx/unit/Context.java68
-rw-r--r--src/java/nginx/unit/Response.java21
2 files changed, 85 insertions, 4 deletions
diff --git a/src/java/nginx/unit/Context.java b/src/java/nginx/unit/Context.java
index 5f7ec22f..0197858b 100644
--- a/src/java/nginx/unit/Context.java
+++ b/src/java/nginx/unit/Context.java
@@ -443,7 +443,7 @@ public class Context implements ServletContext, InitParams
.enableClassInfo()
.enableAnnotationInfo()
//.enableSystemPackages()
- .whitelistModules("javax.*")
+ .acceptModules("javax.*")
//.enableAllInfo()
;
@@ -1214,6 +1214,16 @@ public class Context implements ServletContext, InitParams
processXmlInitParam(reg, (Element) child_node);
continue;
}
+
+ if (tag_name.equals("filter-name")
+ || tag_name.equals("#text")
+ || tag_name.equals("#comment"))
+ {
+ continue;
+ }
+
+ log("processWebXml: tag '" + tag_name + "' for filter '"
+ + filter_name + "' is ignored");
}
filters_.add(reg);
@@ -1306,6 +1316,22 @@ public class Context implements ServletContext, InitParams
reg.setLoadOnStartup(Integer.parseInt(child_node.getTextContent().trim()));
continue;
}
+
+ if (tag_name.equals("jsp-file")) {
+ reg.setJspFile(child_node.getTextContent().trim());
+ continue;
+ }
+
+ if (tag_name.equals("servlet-name")
+ || tag_name.equals("display-name")
+ || tag_name.equals("#text")
+ || tag_name.equals("#comment"))
+ {
+ continue;
+ }
+
+ log("processWebXml: tag '" + tag_name + "' for servlet '"
+ + servlet_name + "' is ignored");
}
servlets_.add(reg);
@@ -1888,6 +1914,7 @@ public class Context implements ServletContext, InitParams
private boolean initialized_ = false;
private final List<FilterMap> filters_ = new ArrayList<>();
private boolean system_jsp_servlet_ = false;
+ private String jsp_file_;
private MultipartConfigElement multipart_config_;
public ServletReg(String name, Class<?> servlet_class)
@@ -1921,6 +1948,21 @@ public class Context implements ServletContext, InitParams
trace("ServletReg.init(): " + getName());
+ if (jsp_file_ != null) {
+ setInitParameter("jspFile", jsp_file_);
+ jsp_file_ = null;
+
+ ServletReg jsp_servlet = name2servlet_.get("jsp");
+
+ if (jsp_servlet.servlet_class_ != null) {
+ servlet_class_ = jsp_servlet.servlet_class_;
+ } else {
+ setClassName(jsp_servlet.getClassName());
+ }
+
+ system_jsp_servlet_ = jsp_servlet.system_jsp_servlet_;
+ }
+
if (system_jsp_servlet_) {
JasperInitializer ji = new JasperInitializer();
@@ -1972,6 +2014,10 @@ public class Context implements ServletContext, InitParams
throw new IllegalStateException("Class already initialized");
}
+ if (jsp_file_ != null) {
+ throw new IllegalStateException("jsp-file already initialized");
+ }
+
super.setClassName(class_name);
}
@@ -1985,11 +2031,31 @@ public class Context implements ServletContext, InitParams
throw new IllegalStateException("Class already initialized");
}
+ if (jsp_file_ != null) {
+ throw new IllegalStateException("jsp-file already initialized");
+ }
+
super.setClassName(servlet_class.getName());
servlet_class_ = servlet_class;
getAnnotationMultipartConfig();
}
+ public void setJspFile(String jsp_file) throws IllegalStateException
+ {
+ if (servlet_ != null
+ || servlet_class_ != null
+ || getClassName() != null)
+ {
+ throw new IllegalStateException("Class already initialized");
+ }
+
+ if (jsp_file_ != null) {
+ throw new IllegalStateException("jsp-file already initialized");
+ }
+
+ jsp_file_ = jsp_file;
+ }
+
private void getAnnotationMultipartConfig() {
if (servlet_class_ == null) {
return;
diff --git a/src/java/nginx/unit/Response.java b/src/java/nginx/unit/Response.java
index 099d7f15..268b359d 100644
--- a/src/java/nginx/unit/Response.java
+++ b/src/java/nginx/unit/Response.java
@@ -40,11 +40,13 @@ public class Response implements HttpServletResponse {
private String characterEncoding = defaultCharacterEncoding;
private String contentType = null;
private String contentTypeHeader = null;
+ private Locale locale = null;
private static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
private static final Charset UTF_8 = StandardCharsets.UTF_8;
private static final String CONTENT_TYPE = "Content-Type";
+ private static final byte[] CONTENT_LANGUAGE_BYTES = "Content-Language".getBytes(ISO_8859_1);
private static final byte[] SET_COOKIE_BYTES = "Set-Cookie".getBytes(ISO_8859_1);
private static final byte[] EXPIRES_BYTES = "Expires".getBytes(ISO_8859_1);
@@ -590,9 +592,13 @@ public class Response implements HttpServletResponse {
@Override
public Locale getLocale()
{
- log("getLocale");
+ trace("getLocale");
- return null;
+ if (locale == null) {
+ return Locale.getDefault();
+ }
+
+ return locale;
}
@Override
@@ -795,7 +801,16 @@ public class Response implements HttpServletResponse {
@Override
public void setLocale(Locale loc)
{
- log("setLocale: " + loc);
+ trace("setLocale: " + loc);
+
+ if (loc == null || isCommitted()) {
+ return;
+ }
+
+ locale = loc;
+ String lang = locale.toString().replace('_', '-');
+
+ setHeader(req_info_ptr, CONTENT_LANGUAGE_BYTES, lang.getBytes(ISO_8859_1));
}
private void log(String msg)