读书人

servlet入门有关问题超级简单

发布时间: 2012-03-15 11:50:38 作者: rapoo

servlet入门问题,超级简单!
下面是一段最简单的servlet结构,俺是刚刚接触,怎么具体内容要写在异常里呀?

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletTemplate extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// Use "request " to read incoming HTTP headers
// (e.g., cookies) and query data from HTML forms.
// Use "response " to specify the HTTP response status
// code and headers (e.g., the content type, cookies).
PrintWriter out = response.getWriter();
// Use "out " to send content to browser.
}
}

[解决办法]
楼主什么意思?
[解决办法]
throws ServletException, IOException 并不代码是写在异常里。

而是表示doGet方法有可能会抛出ServletException、IOException 2种异常

读书人网 >Java Web开发

热点推荐