package myapp;

import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;


public class ListServlet extends HttpServlet {
  InputOutPut io=new InputOutPut();

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    resp.setContentType("text/plain");
    List<String> list=new ArrayList<>();
    list.add("String in list");
    try{
    io.write(list);
    resp.getWriter().println(io.read().get(0));
    }
    catch(Exception e){
      resp.getWriter().println(e.getMessage());
    }
  }
}

@@ -504,16 +504,14 @@
     
-try%7B
 %0A   
+//
  io.
@@ -522,24 +522,26 @@
 e(list);%0A   
+//
  resp.getWri
@@ -577,40 +577,8 @@
 ));%0A
-    %7D%0A    catch(Exception e)%7B%0A  
     
@@ -606,29 +606,26 @@
 tln(
-e.getMessage(
+list.get(0
 ));%0A    
 %7D%0A  
@@ -620,16 +620,20 @@
 ));%0A    
-%7D
+%0A    
 %0A  %7D%0A%7D%0A

Update ListServlet.java