servlets - response sendRedirect giving 404 error -


I'm trying to redirect to an error page on some of the terms in your servlet code. But nothing is working so far.

So I am using Weblogic 10.x as my app server. I'm directly applying applications directly to managed servers using the console.

So basically I issue them as .war files and deploy them as webapp.

  public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {try {throw new Exception ( "503_Exception"); } Hold (exception e) {response.sendRedirect (response.encodeRedirectURL (HandleError.handle (e, request))); }} Public class handles error {public static string handles (Throabl 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"; }}   

War File Structure

  - & gt; Jsp-> Error- & gt; Custom.html - & gt; Web-inf - & gt; Web -inf- & gt; Classes- gt; Project 2- & gt; Class 1 Class   

http: // machinename: 3030 / Application3-Project2-context-root - & Gt; Redirects - & gt; http: // machineNAME: 3030 / jsp / error / custom.html - & gt; & Gt; Where the actual reference route is unavailable.

Error 404 - RFC 2068 not found by hypertext transfer protocol - HTTP / 1.1: 10.4.5 404 not found

The server requested - Nothing has been found by matching URI, no indication has been provided whether the situation is temporary or permanent.

If the server does not want to make this information available to the customer, then the status code 403 (prohibited) can be used instead.

But if I'm - 410 (Gun) should be used for status code if the server must know through qualified systems configured as internal, then an old resource Is permanently unavailable and there is no forwarding address for this.

  response.sendRedirect (response.encodeRedirectURL (request.getContextPath ()) + HandleError.handle (e request)));   

I call error 310 (pure :: ERR_TOO_MANY_REDIRECTS) in Chrome and FF error: Many redirects

Can anyone help me? Thanks in advance. :)

add request request.getServletContext (). This is a good way to start in GetContextPath () but you are clearly entering the endless redirection loop. Do not forget to log in with your exception, thus you will be able to see what is the problem.

Comments