I have an unreported exception coming up when I try to compile my servlet. I can't figure out why. Can anyone help me? The exception says "unreported exception java.langClassNotFoundException; must be caught or declared to be thrown votes = (int [] indat.readObject();"
Here's my code:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Survey extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { int votes[] = null; int index; int vote; File survdat = new File("survdat.dat"); String gender; String products[] = {"Conventional TX", "HDTV", "VCR", "CD Player/recorder", "DIVD player", "Other"};
// Set the content type for the response output and get a writer
try{ if (survdat.exists()) { ObjectInputStream indat = new ObjectInputStream(new FileInputStream(survdat)); votes = (int []) indat.readObject(); indat.close(); } // If file does not exist (this is the first vote), create votes array
else votes = new int[14]; }catch(Exception ex){// code comes here if an exception is raised}