See Thread at: http://www.techienuggets.com/Detail?tx=12338 Posted on behalf of 
a User

It didn't work. I got a 500 later in my code. Here's what I did:

        if(detail.size() > 0)
        {
            dbutil = new 
DBUtil(getServletConfig().getInitParameter(Constants.JNDI_NAME));        
            dbutil.executeNoResults(updateSql);
            dbutil.cleanup();
            session.setAttribute("title", title);
            session.setAttribute("desc", title);
            session.setAttribute("keywords", keywords);
            dispatcher = 
getServletContext().getRequestDispatcher("/displayArticle.jsp");
        }
        else
            response.sendError(404, "");
//         dispatcher = getServletContext().getRequestDispatcher("/404.jsp");

Notice I commented out the code that would later dispatch to 404.jsp.

Here's my entry from web.xml:

  </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
    </error-page>

Looks like the 404 page isn't being invoked by the response.sendError(404, "");


In Response To: 

[EMAIL PROTECTED] wrote:
> See Thread at: http://www.techienuggets.com/Detail?tx=12338 Posted on behalf 
> of a User
> 
> I have a J2EE application residing on Tomcat. The pages are dynamically 
> generated. If a use enters an invalid request I redirect him to a generic 
> error page (which isn't really an error page but just a jsp that display a 
> message and allows a redirect back to the site's main page). I would like to 
> return a status of 404 from this page but because the page gets served 
> properly I am returning a status of 200. The problem with this is that my 
> error page than gets indexed by search engines. Any advise on how to tackle 
> this?

Servlet docs suggest you can nominate your JSP as an
error page for status 404 - in Tomcat you could put
this in conf/web.xml (after <welcome-file-list>)

   <error-page>
     <error-code>404</error-code>
     <location>/my_error_404.jsp</location>
  </error-page>

then if you call response.sendError(404, "") when your
app decides the request isn't sensible, this page will
be used.  I haven't tried this.

Paul Singleton


---------------------------------------------------------------------
To start a new topic, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to