Look for a precompilation request as described in Section 8.4.2 of the JSP 1.2 Specification. WARNING - we cannot use request.getParameter() for this, because that will trigger parsing all of the request parameters, and not give a servlet the opportunity to
(HttpServletRequest request)
| 200 | * specified |
| 201 | */ |
| 202 | boolean preCompile(HttpServletRequest request) throws ServletException { |
| 203 | |
| 204 | String precompileParameter = rctxt.getOptions().getJspPrecompilationQueryParameter(); |
| 205 | String queryString = request.getQueryString(); |
| 206 | if (queryString == null) { |
| 207 | return false; |
| 208 | } |
| 209 | int start = queryString.indexOf(precompileParameter); |
| 210 | if (start < 0) { |
| 211 | return false; |
| 212 | } |
| 213 | queryString = queryString.substring(start + precompileParameter.length()); |
| 214 | if (queryString.isEmpty()) { |
| 215 | return true; // ?jsp_precompile |
| 216 | } |
| 217 | if (queryString.startsWith("&")) { |
| 218 | return true; // ?jsp_precompile&foo=bar... |
| 219 | } |
| 220 | if (!queryString.startsWith("=")) { |
| 221 | return false; // part of some other name or value |
| 222 | } |
| 223 | int limit = queryString.length(); |
| 224 | int ampersand = queryString.indexOf('&'); |
| 225 | if (ampersand > 0) { |
| 226 | limit = ampersand; |
| 227 | } |
| 228 | String value = queryString.substring(1, limit); |
| 229 | if (value.equals("true")) { |
| 230 | return true; // ?jsp_precompile=true |
| 231 | } else if (value.equals("false")) { |
| 232 | // Spec says if jsp_precompile=false, the request should not |
| 233 | // be delivered to the JSP page; the easiest way to implement |
| 234 | // this is to set the flag to true, and precompile the page anyway. |
| 235 | // This still conforms to the spec, since it says the |
| 236 | // precompilation request can be ignored. |
| 237 | return true; // ?jsp_precompile=false |
| 238 | } else { |
| 239 | throw new ServletException( |
| 240 | Localizer.getMessage("jsp.error.precompilation.parameter", precompileParameter, value)); |
| 241 | } |
| 242 | |
| 243 | } |
| 244 | |
| 245 | |
| 246 | @Override |
no test coverage detected