Dennis
Posts: 2
Nickname: vedo
Registered: Jan, 2003
|
|
Cannot Resolve Symbol error in Servlet
|
Posted: Jan 13, 2003 4:02 PM
|
|
I'm having difficulty getting my servlet to compile. I get 2 errors - both "cannot resolve symbol" errors, both are for "variable response" which is not a variable. Can anyone help? Here's the code:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Survey extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse respone) 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
response.setContentType( "text/html" ); PrintWriter servletOut = response.setWriter();
// Produce the head of the output document
servletOut.print("<html><head>"); servletOut.println( "<title> Return message </title></head><body>");
// If the file already exists, read in its data
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];
// Get the gender of the survey respondee
gender = request.getParameter("gender");
// Add the consume electronics vote of the response to the votes array
vote = Integer.parseInt(request.getParameter("vote")); if (gender.equals("male")) vote += 7; votes[vote]++;
// Write updates votes array to disk
ObjectOutputStream outdat = new ObjectOutputStream( new FileOutputStream(survdat)); outdat.writeObject(votes); outdat.flush(); outdat.close();
// Create the initial response information
servletOut.println("<h3>Thank You...</h3>"); servletOut.println("<h4>Current Survey Results:</h4>");
// Create the ttal votes return information for female respondents
servletOut.println("<h5>For Female Respondents </h5>"); for (index = 0; index < 7; index++) { servletOut.print(products[index]); servletOut.print(": "); servletOut.println(votes[index]); servletOut.println("<br />"); }
// Create the total votes return information for male respondents
servletOut.println("<h5>For Male Respondents </h5>"); for (index = 0; index < 7; index++) { servletOut.print(products[index - 7]); servletOut.print(": "); servletOut.println(votes[index]); servletOut.println("<br />"); } servletOut.close(); } }
|
|