• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compiling servlets

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>");
}
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>");
}
}


 
reply
    Bookmark Topic Watch Topic
  • New Topic