jsf - Custom error page - get originally requested URL -


problem

this follow-up yesterday's (unanswered) question (see here) try find alternative approach.

i added basic

    <error-page>               <error-code>404</error-code>               <location>/404search.jsf</location>       </error-page> 

..to web.xml. need url user entered submit search function, manage current url (in case, ...404search.jsf) instead of actual query user entered.

attempts

  • httpservletrequest.getrequesturl returns http://www.website.com/foldername/404search.jsf
  • httpservletrequest.getrequesturi returns /foldername/404search.jsf
  • httpservletrequest.getquerystring returns nothing @ all

i want return /foldername/wrong-url-the-user-entered#anchor-if-there-is-any

details...

the idea url user entered (such www.site.com/product/99999-product-that-cant-be-found or www.site.com/faq/support-question-that-doesnt-exist), regex remove hyphens , run search query 99999 product cant found or support question doesnt exist.

any suggestions?

the <error-page> under covers served requestdispatcher#forward() call. details of original request available request attribues keyed keys identified requestdispatcher#forward_xxx constants:

you starter should know request attributes in el available via implicit el object #{requestscope}.

so, all, should in view:

<p>unfortunately, page requested, #{requestscope['javax.servlet.forward.request_uri']} not exist</p> 

and equivalently, should in bean, if necessary:

string forwardrequesturi = externalcontext.getrequestmap().get(requestdispatcher.forward_request_uri); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -