The Artima Developer Community
Sponsored Link

Java Answers Forum
Cannot Resolve Symbol error in Servlet

1 reply on 1 page. Most recent reply: Jan 13, 2003 4:28 PM by Dennis

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Dennis

Posts: 2
Nickname: vedo
Registered: Jan, 2003

Cannot Resolve Symbol error in Servlet Posted: Jan 13, 2003 4:02 PM
Reply to this message Reply
Advertisement
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();
}
}


Dennis

Posts: 2
Nickname: vedo
Registered: Jan, 2003

Re: Cannot Resolve Symbol error in Servlet Posted: Jan 13, 2003 4:28 PM
Reply to this message Reply
Spelled response wrong in declaration. Duh.

Flat View: This topic has 1 reply on 1 page
Topic: using api in java Previous Topic   Next Topic Topic: String arrays

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use