Skip to content

Commit b18342a

Browse files
committed
Removing try/resources so that the stream is not closed and error handling is reported correctly
1 parent ad2fc34 commit b18342a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

ejb/stateless/src/main/java/org/javaee7/ejb/stateless/remote/TestServlet.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
*/
5454
@WebServlet(urlPatterns = {"/TestServletWithInterface"})
5555
public class TestServlet extends HttpServlet {
56-
56+
5757
// Cannot be injected using @Inject
58-
@EJB Account bean;
58+
@EJB
59+
Account bean;
5960

6061
/**
6162
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
@@ -69,20 +70,19 @@ public class TestServlet extends HttpServlet {
6970
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
7071
throws ServletException, IOException {
7172
response.setContentType("text/html;charset=UTF-8");
72-
try (PrintWriter out = response.getWriter()) {
73-
out.println("<!DOCTYPE html>");
74-
out.println("<html>");
75-
out.println("<head>");
76-
out.println("<title>Stateless Bean (with Interface)</title>");
77-
out.println("</head>");
78-
out.println("<body>");
79-
out.println("<h1>Stateless Bean (with Interface)</h1>");
80-
out.println("<h2>Withdraw/Deposit</h2>");
81-
bean.deposit((float)10.0);
82-
out.println("Withdrawn : " + bean.withdraw());
83-
out.println("</body>");
84-
out.println("</html>");
85-
}
73+
PrintWriter out = response.getWriter();
74+
out.println("<!DOCTYPE html>");
75+
out.println("<html>");
76+
out.println("<head>");
77+
out.println("<title>Stateless Bean (with Interface)</title>");
78+
out.println("</head>");
79+
out.println("<body>");
80+
out.println("<h1>Stateless Bean (with Interface)</h1>");
81+
out.println("<h2>Withdraw/Deposit</h2>");
82+
bean.deposit((float) 10.0);
83+
out.println("Withdrawn : " + bean.withdraw());
84+
out.println("</body>");
85+
out.println("</html>");
8686
}
8787

8888
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">

0 commit comments

Comments
 (0)