title: response sendRedirect giving 404 error
body: <p>I am trying to redirect to an error page upon some condition in my servlet code. But until now nothing is working out.</p>
  
  <p>So I am using weblogic 10.x as my app server. am deploying apps directly into managed servers using the console.</p>
  
  <p>So basically i jar them up as .war files and deploy them as webapps. </p>
  
  <pre><code>   public void doGet (HttpServletRequest request, HttpServletResponse response)
        throws IOException , ServletException
     {
        try
         {
                    throw new Exception("503_Exception") ;                 
          }
          catch(Exception e)
          {
                    response.sendRedirect(response.encodeRedirectURL(HandleError.handle(e, request)));
         }
     }   
  
  
  public class HandleError{
      public static String handle(Throwable t, javax.servlet.http.HttpServletRequest request)
      { 
           String sErrorMsg = t.getMessage();
  
           if (sErrorMsg.equals("503_Exception")) {
              request.setAttribute("msg", "INVALID SESSION");
              return "/jsp/error/custom.html";
           }
           return "/default_error.html";
      }
  }
  </code></pre>
  
  <p>war file structure </p>
  
  <pre><code>-&gt;jsp-&gt;error-&gt;custom.html
  -&gt;web-inf
  -&gt;web-inf-&gt;classes-&gt;project2-&gt;Class1.class
  </code></pre>
  
  <p><strong>http://machineNAME:3030/Application3-Project2-context-root</strong> ->redirects to -><strong>http://machineNAME:3030/jsp/error/custom.html</strong> -->> where the actual context root is missing ..</p>
  
  <blockquote>
    <p>Error 404--Not Found From RFC 2068
    Hypertext Transfer Protocol --
    HTTP/1.1:
    10.4.5 404 Not Found</p>
    
    <p>The server has not found anything
    matching the Request-URI. No
    indication is given of whether the
    condition is temporary or permanent.</p>
    
    <p>If the server does not wish to make
    this information available to the
    client, the status code 403
    (Forbidden) can be used instead. The
    410 (Gone) status code SHOULD be used
    if the server knows, through some
    internally configurable mechanism,
    that an old resource is permanently
    unavailable and has no forwarding
    address.</p>
  </blockquote>
  
  <p>But if i give - </p>
  
  <pre><code>response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + HandleError.handle(e, request)));
  </code></pre>
  
  <p>i get <strong>Error 310 (net::ERR_TOO_MANY_REDIRECTS):</strong> in chrome and in FF error says <strong>too many re-directions</strong> .</p>
  
  <p>Could someone help me out ?
  thanks in advance. :) </p>