summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-10-30 17:33:36 +0300
committerMax Romanov <max.romanov@nginx.com>2020-10-30 17:33:36 +0300
commitbbe4b97ca159bbff19e3c507635e0d81a68c695e (patch)
tree57fdcd63829b8bc1b5ad3871b479a4356086d25c
parent50af47fd7c03aecb5bb9f248cac8ccbdb65c9b4c (diff)
downloadunit-bbe4b97ca159bbff19e3c507635e0d81a68c695e.tar.gz
unit-bbe4b97ca159bbff19e3c507635e0d81a68c695e.tar.bz2
Java: supporting jsp-file attribute for servlet.
This closes #487 issue on GitHub.
-rw-r--r--src/java/nginx/unit/Context.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/java/nginx/unit/Context.java b/src/java/nginx/unit/Context.java
index 5f7ec22f..5aa3a982 100644
--- a/src/java/nginx/unit/Context.java
+++ b/src/java/nginx/unit/Context.java
@@ -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;