Hi I'm trying to run a
servlet but i'm getting this exception on compiling the servlet My program is
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends javax.servlet.http.HttpServlet {
public void doPost(HttpServletRequest req,HttpServlet res) throws
ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String id=req.getParameter("id");
String password =req.getParamter("ped");
out.println("<HTML><BODY>");
if("jsmith".equalsIgnorecase(id) && "Spring12".equalIgnoreCase(password))
{
out.println("Hello "+ id +". Welcome to our magazines! ");
}
else{
out.println("Invalid ID or password");
}
out.println("<BODY></HTML>");
}
}
The exception is
LoginServlet.java:14: cannot find symbol
symbol : method setContentType(java.lang.String)
location: class javax.servlet.http.HttpServlet
res.setContentType("text/html");
Please help.
Thanks.