import java.io.*;
import javax.servlet.*;
import javax.servlet.httpservlet.*;
public class FirstServlet extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
res.sendRedirect("/FirstServlet/index.html");
}
}//end of get
public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String name= req.getParameter("name");
if(name.equals("")){
res.sendRedirect("/FirstServlet/ContacUs.html");
}else{
requestDispatcher rd= req.getRequestDispatcher("/second");
rd.forward(req,res);
}
}//end of post
}
-----
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\FirstServletTrial
\WEB-INF\src>javac -d . *.java
FirstServlet.java:19: error: class, interface, or enum expected
public void doPost(HttpServletRequest req, HttpServletResponse res)throws Servle
tException,IOException{
^
FirstServlet.java:22: error: class, interface, or enum expected
PrintWriter out=res.getWriter();
^
FirstServlet.java:24: error: class, interface, or enum expected
String name= req.getParameter("name");
^
FirstServlet.java:25: error: class, interface, or enum expected
if(name.equals("")){
^
FirstServlet.java:27: error: class, interface, or enum expected
}else{
^
FirstServlet.java:29: error: class, interface, or enum expected
rd.forward(req,res);
^
FirstServlet.java:30: error: class, interface, or enum expected
}
^
7 errors
Radhijavadev 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.