Adds servlet declaration and mapping for the JSP page servlet to the generated web.xml fragment. @param file Context-relative path to the JSP file, e.g. /index.jsp @param clctxt Compilation context of the servlet @throws IOException An IO error occurred
(String file, JspCompilationContext clctxt)
| 1219 | * @throws IOException An IO error occurred |
| 1220 | */ |
| 1221 | public void generateWebMapping(String file, JspCompilationContext clctxt) throws IOException { |
| 1222 | if (log.isDebugEnabled()) { |
| 1223 | log.debug(Localizer.getMessage("jspc.generatingMapping", file, clctxt)); |
| 1224 | } |
| 1225 | |
| 1226 | String className = clctxt.getServletClassName(); |
| 1227 | String packageName = clctxt.getServletPackageName(); |
| 1228 | |
| 1229 | String thisServletName; |
| 1230 | if (packageName.isEmpty()) { |
| 1231 | thisServletName = className; |
| 1232 | } else { |
| 1233 | thisServletName = packageName + '.' + className; |
| 1234 | } |
| 1235 | |
| 1236 | if (servletout != null) { |
| 1237 | synchronized (servletout) { |
| 1238 | servletout.write("\n <servlet>\n <servlet-name>"); |
| 1239 | servletout.write(thisServletName); |
| 1240 | servletout.write("</servlet-name>\n <servlet-class>"); |
| 1241 | servletout.write(thisServletName); |
| 1242 | servletout.write("</servlet-class>\n </servlet>\n"); |
| 1243 | } |
| 1244 | } |
| 1245 | if (mappingout != null) { |
| 1246 | synchronized (mappingout) { |
| 1247 | mappingout.write("\n <servlet-mapping>\n <servlet-name>"); |
| 1248 | mappingout.write(thisServletName); |
| 1249 | mappingout.write("</servlet-name>\n <url-pattern>"); |
| 1250 | mappingout.write(file.replace('\\', '/')); |
| 1251 | mappingout.write("</url-pattern>\n </servlet-mapping>\n"); |
| 1252 | } |
| 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | /** |
| 1257 | * Include the generated web.xml inside the webapp's web.xml. |
no test coverage detected