View | Details | Raw Unified | Return to bug 42693
Collapse All | Expand All

(-)java/org/apache/jasper/compiler/Compiler.java (-15 / +23 lines)
Lines 141-164 Link Here
141
141
142
        ctxt.checkOutputDir();
142
        ctxt.checkOutputDir();
143
        String javaFileName = ctxt.getServletJavaFileName();
143
        String javaFileName = ctxt.getServletJavaFileName();
144
144
        ServletWriter writer = null;
145
        ServletWriter writer = null;
145
146
        try {
146
        try {
147
            // Setup the ServletWriter
148
            String javaEncoding = ctxt.getOptions().getJavaEncoding();
149
            OutputStreamWriter osw = null;
150
147
151
            try {
152
                osw = new OutputStreamWriter(
153
                        new FileOutputStream(javaFileName), javaEncoding);
154
            } catch (UnsupportedEncodingException ex) {
155
                errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
156
                        javaEncoding);
157
            }
158
159
            writer = new ServletWriter(new PrintWriter(osw));
160
            ctxt.setWriter(writer);
161
162
            // Reset the temporary variable counter for the generator.
148
            // Reset the temporary variable counter for the generator.
163
            JspUtil.resetTemporaryVariableName();
149
            JspUtil.resetTemporaryVariableName();
164
150
Lines 168-173 Link Here
168
154
169
            if (ctxt.isPrototypeMode()) {
155
            if (ctxt.isPrototypeMode()) {
170
                // generate prototype .java file for the tag file
156
                // generate prototype .java file for the tag file
157
                writer = setupContextWriter(javaFileName);
171
                Generator.generate(writer, this, pageNodes);
158
                Generator.generate(writer, this, pageNodes);
172
                writer.close();
159
                writer.close();
173
                writer = null;
160
                writer = null;
Lines 207-212 Link Here
207
            ELFunctionMapper.map(this, pageNodes);
194
            ELFunctionMapper.map(this, pageNodes);
208
195
209
            // generate servlet .java file
196
            // generate servlet .java file
197
            writer = setupContextWriter(javaFileName);
210
            Generator.generate(writer, this, pageNodes);
198
            Generator.generate(writer, this, pageNodes);
211
            writer.close();
199
            writer.close();
212
            writer = null;
200
            writer = null;
Lines 259-264 Link Here
259
        return smapStr;
247
        return smapStr;
260
    }
248
    }
261
249
250
	private ServletWriter setupContextWriter(String javaFileName)
251
			throws FileNotFoundException, JasperException {
252
		ServletWriter writer;
253
		// Setup the ServletWriter
254
		String javaEncoding = ctxt.getOptions().getJavaEncoding();
255
		OutputStreamWriter osw = null;
256
257
		try {
258
		    osw = new OutputStreamWriter(
259
		            new FileOutputStream(javaFileName), javaEncoding);
260
		} catch (UnsupportedEncodingException ex) {
261
		    errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
262
		            javaEncoding);
263
		}
264
265
		writer = new ServletWriter(new PrintWriter(osw));
266
		ctxt.setWriter(writer);
267
		return writer;
268
	}
269
262
    /**
270
    /**
263
     * Compile the servlet from .java file to .class file
271
     * Compile the servlet from .java file to .class file
264
     */
272
     */

Return to bug 42693