#################Servlet 的问题 ############
本文导语: servlet的源程序如下: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloServlet extends HttpServlet { int number; public void init(servletconfig conf) throws servletException { super.init(conf); number=0; } public...
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet
{
int number;
public void init(servletconfig conf) throws servletException
{
super.init(conf);
number=0;
}
public void service(HttpServletRequest req,HttpServletResponse res) throws IOException
{
//获得一个于浏览器联结的链路,用于发送发出结果
ServletOutputStream out=res.getOutputStream;
res.setContentType("html/text");
out.println("Servlet Test");
out.println("It is ok!");
out.println(req.getParameter("userName"));
out.println("
U are caller Number");
number++;
out.println(Integer.toString(number));
out.close();
// close the output stream
}
public String getServletInfo()
{
return"Hello world Servlet!";
}
}
编译时出现如下问题:
D:jsdkwebpagesWEB-INFservlets>javac HelloServlet.java
HelloServlet.java:8:cannot resolve symbol
symbol:class servletconfig
location:class HelloServlet
public void init(servletconfig conf) throws servletException
HelloServlet.java:17:cannot resolve symbol
symbol: variable getOutputStream
location:interface javax.servlet.http.HttpServletResponse
ServletOutputStream out=res.getOutputStream;
2 errors
|
那改怎么改??
|
ServletConfig conf
|
第二个错误好象应该是res.getOutputStream()吧?
|
res.getOutputStream()