Jak wysłać błąd HTTP dla usługi WWW Java RESTful?
ja to zrobiłemseminarium a teraz chcę rzucić błąd z tej usługi, jak kod błędu HTTP403
lub400
.
Jak mogę to zrobić? Zauważyłem, że mam interfejs typuHttpServletResponse
, ale nie wiem, jak mogę to wykorzystać. Czy muszę importować coś innego?
import java.util.Date;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.xml.ws.http.HTTPException;
import sun.awt.RequestFocusController;
import com.sun.jersey.spi.resource.Singleton;
import com.sun.research.ws.wadl.Request;
import com.sun.research.ws.wadl.Response;