Code in the chapter "Handling server-side
exceptions":
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
String category = req.getParameter("category");
if( !loggedIn(req) )
{
//Set the status code to 403 if the user is not logged in.
//we may also use setStatus().
res.sendError(res.SC_FORBIDDEN);
return;
}
Vector items = new Vector();
try
{
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"select * from ITEM where CATEGORY=' "+category+"' "
);
while(rs.next())
{
items.addElement(rs.getString("name"));
}
}
catch(SQLException e)
{
//wrap the exception in a ServletException and rethrow
throw new ServletException("Wrapped SQLException", e);
}
}
my question is :Why the doGet() method didn't need "thows" clause because there is "throw" in the catch block and not catch the Exception in outside?