This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
HI, I have written a simple servlet and tried compiling in the dos prompt givin javac Servlet01.java. but it gives me an error on line 11 saying class printWriter not found. can someone pl explain the error. Also, once i compile the servlet how do i view it in the browser. is there any good notes available on the web for compiling and running servlets. import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Servlet01 extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException{ res.setContentType("text/html"); printWriter out = res.getWriter(); // line 11 out.println("<HTML>"); out.println("<HEAD><TITLE = SERVLET01></TITLE></HEAD>"); out.println("<BODY>"); out.println("Hello Big World"); out.println("</BODY></HTML>"); } }
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
1
posted
0
Thats an easy one - the class you want is PrintWriter Note the upper case first letter. Java style calls for class names to start with a upper case letter, while variable names start with lower case. Bill ------------------ author of:
Your printWriter is in lower case. Type it in uppercase as PrintWriter and try it.
Originally posted by vidhya subramaniam: HI, I have written a simple servlet and tried compiling in the dos prompt givin javac Servlet01.java. but it gives me an error on line 11 saying class printWriter not found. can someone pl explain the error. Also, once i compile the servlet how do i view it in the browser. is there any good notes available on the web for compiling and running servlets. import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Servlet01 extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException{ res.setContentType("text/html"); printWriter out = res.getWriter(); // line 11 out.println("<HTML>"); out.println("<HEAD><TITLE = SERVLET01></TITLE></HEAD>"); out.println("<BODY>"); out.println("Hello Big World"); out.println("</BODY></HTML>"); } }