Deprecated API

Contents

  • Deprecated Interfaces
    Interface
    Description
    v7.0 Application developers requiring this functionality should implement this using com.ibm.websphere.servlet.request.IRequest.
    v7.0 Application developers requiring this functionality should implement this using com.ibm.websphere.servlet.response.IResponse.
  • Deprecated Classes
    Class
    Description
    Application developers requiring this functionality should implement this using javax.servlet.filter classes.
    Application developers requiring this functionality should implement this using javax.servlet.filter classes.
    Application developers requiring this functionality should implement this using javax.servlet.filter classes.
    Application developers requiring this functionality should implement this using javax.servlet.filter classes.
    since WAS V6.0 Use the HttpServletRequestWrapper class instead. Proxies function invocations to an underlying HttpServletRequest. Subclasses of this class can be created that overload or enhance the functionality of a server-provided HttpServletRequest.

    Using the proxied request:

    1. Subclass this class and overload any desired functions.
    2. During the servlet's service method, create an instance of the enhanced request using the original request from the server as the proxied request.
    3. Forward the enhanced request to another servlet for processing instead of the original request that was provided by the server.

    Sample subclass (overloads the request's InputStream)

     
     // This enhanced request will force the request to be a POST request.
     // This request POST data input will be read from a specified file.
     public class PostedFileRequest extends HttpServletRequestProxy{
        private HttpServletRequest _request;
        private File _file;
        public PostedFileRequest(File f, HttpServletRequest req){
          _file =f;
           _request = req;
        }
        protected HttpServletRequest getProxiedHttpServletRequest(){
           return _request;
        }
        //overload request functionality
        public ServletInputStream getInputStream() throws IOException{
           return new ServletInputStreamAdapter(new FileInputStream(_file));
        }
        public BufferedReader getReader() throws IOException{
           return new BufferedReader(getInputStream());
        }
        public String getMethod(){
           //force the HTTP method to be POST.
           return "POST";
        }
     }
     

    Using the enhanced request subclass transparently in a servlet

     //This servlet posts a data file as a request to another servlet.
     public class PostGeneratorServlet extends HttpServlet{
        public void service HttpServletRequest req, HttpServletResponse resp){
           req = new PostedFileRequest(req, new File(request.getPathTranslated()));
           //forward the enhanced request to be used transparently by another servlet.
           getServletContext().getRequestDispatcher("/postHandlerServlet").forward(req, resp);
        }
     }
     
    since WAS V6.0 Use the HttpServletResponseWrapper class instead. Proxies function invocations to an underlying HttpServletResponse. Subclasses of this class can be created that overload or enhance the functionality of a server-provided HttpServletResponse.

    Using the proxied response:

    1. Subclass this class and overload any desired functions.
    2. During the servlet's service method, create an instance of the enhanced response using the original response from the server as the proxied response.
    3. Forward the enhanced response to another servlet for processing instead of the original response that was provided by the server.

    Sample subclass (overloads the response's OutputStream)

     
     //The data written to this response will be saved to the specified file.
     public class FileOutputResponse extends HttpServletResponseProxy{
        private HttpServletResponse _response;
        private File _file;
        public FileOutputResponse(File f, HttpServletResponse resp){
          _file = f;
           _response = resp;
        }
        protected HttpServletResponse getProxiedHttpServletResponse(){
           return _response;
        }
        //overload response functionality
        public ServletOutputStream getOutputStream() throws IOException{
           return new ServletOutputStreamAdapter(new FileOutputStream(_file));
        }
        public PrintWriter getWriter() throws IOException{
           return new PrintWriter(getOutputStream());
        }
     }
     

    Using the enhanced response subclass transparently in a servlet

     //This servlet will store the response of another servlet to a file.
     public class SaveResponseToFileServlet extends HttpServlet{
        public void service(HttpServletRequest req, HttpServletResponse resp){
           resp = new FileOutputResponse(req, new File("/tmp/response.txt"));
    
           //store the response of SnoopServlet to the response.txt file.
           getServletContext().getRequestDispatcher("/servlet/SnoopServlet").forward(req, resp);
        }
     }