aspose file tools*
The moose likes Servlets and the fly likes compiling servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "compiling servlets" Watch "compiling servlets" New topic
Author

compiling servlets

vidhya subramaniam
Ranch Hand

Joined: Jul 14, 2001
Posts: 91
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: 12803
    
    5
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:
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
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>");
}
}

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiling servlets