package cs320; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class coffeeshop */ @WebServlet("/coffeeshop") public class coffeeshop extends HttpServlet { private static final long serialVersionUID = 1L; public void init() throws ServletException{ String file = getServletContext().getRealPath("/WEB-INF/lab1.txt"); try { BufferedReader br = new BufferedReader(new FileReader(file)); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } protected void doGet1(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ response.setContentType("text/html"); /*String fn="/WEB-INF/lab1.text"; ServletContext context= getServletContext(); InputStream is= context.getResourceAsStream(fn); if(is!= null){ InputStreamReader isr=new InputStreamReader(is); BufferedReader reader= new BufferedReader(isr); PrintWriter writer= response.getWriter(); String text= ""; while ((text = reader.readLine())!=null){ writer.println(text); } } */ } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet1(request, response); } }