运行出错?
package class1;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class Sessioncount
*/
@WebServlet("/Sessioncount")
public class Sessioncount extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html;charset=utf");
PrintWriter out=response.getWriter();
int count=0;
HttpSession session=request.getSession();
if(session.getAttribute("count")!=null){
Integer c=(Integer)session.getAttribute("count");
count=c+1;
}
session.setAttribute("count", count);
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet count:"+count+"</h1>");
out.println("<a href='"+response.encodeURL("Sessioncount")+"'>递增</a>");
out.println("</body>");
out.println("</html>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
为什么会运行报错啊?求指点